0
안녕하세요 저는 SQLite에 문제가 있습니다. 나는 travis 튜토리얼을 따라 갔지만 여전히 오류가 발생했으며 며칠 동안 노력하고 있습니다. 누군가가 도와 주셔서 감사합니다. 미리 감사드립니다.오픈시 안드로이드 SQLite 오류
여기
로그 캣
10-17 16:21:57.835: D/AndroidRuntime(2238): Shutting down VM
10-17 16:21:57.835: W/dalvikvm(2238): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
10-17 16:21:57.865: E/AndroidRuntime(2238): FATAL EXCEPTION: main
10-17 16:21:57.865: E/AndroidRuntime(2238): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.sample.sqlite/com.sample.sqlite.SQLite}: java.lang.NullPointerException
10-17 16:21:57.865: E/AndroidRuntime(2238): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
10-17 16:21:57.865: E/AndroidRuntime(2238): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
10-17 16:21:57.865: E/AndroidRuntime(2238): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
10-17 16:21:57.865: E/AndroidRuntime(2238): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
10-17 16:21:57.865: E/AndroidRuntime(2238): at android.os.Handler.dispatchMessage(Handler.java:99)
10-17 16:21:57.865: E/AndroidRuntime(2238): at android.os.Looper.loop(Looper.java:123)
10-17 16:21:57.865: E/AndroidRuntime(2238): at android.app.ActivityThread.main(ActivityThread.java:4627)
10-17 16:21:57.865: E/AndroidRuntime(2238): at java.lang.reflect.Method.invokeNative(Native Method)
10-17 16:21:57.865: E/AndroidRuntime(2238): at java.lang.reflect.Method.invoke(Method.java:521)
10-17 16:21:57.865: E/AndroidRuntime(2238): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
10-17 16:21:57.865: E/AndroidRuntime(2238): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
10-17 16:21:57.865: E/AndroidRuntime(2238): at dalvik.system.NativeStart.main(Native Method)
10-17 16:21:57.865: E/AndroidRuntime(2238): Caused by: java.lang.NullPointerException
10-17 16:21:57.865: E/AndroidRuntime(2238): at com.sample.sqlite.SQLite.onCreate(SQLite.java:28)
10-17 16:21:57.865: E/AndroidRuntime(2238): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
10-17 16:21:57.865: E/AndroidRuntime(2238): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
10-17 16:21:57.865: E/AndroidRuntime(2238): ... 11 more
JAVA 패키지 com.sample.sqlite 내 코드입니다;
import android.app.Activity;
import android.app.Dialog;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class SQLite extends Activity implements OnClickListener {
Button btnUpdate, btnView;
EditText etName, etScore, etCleared;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
btnUpdate = (Button) findViewById(R.id.btnUpdate);
btnView = (Button) findViewById(R.id.btnView);
etName = (EditText) findViewById(R.id.etName);
etScore = (EditText) findViewById(R.id.etScore);
etCleared = (EditText) findViewById(R.id.etCleared);
btnUpdate.setOnClickListener(this);
btnView.setOnClickListener(this);
}
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
switch (arg0.getId()) {
case R.id.btnUpdate:
boolean didItWork = true;
try{
String name = etName.getText().toString();
String score = etScore.getText().toString();
String cleared = etCleared.getText().toString();
Score entry = new Score(SQLite.this);
entry.open();
entry.createEntry(name, score, cleared);
entry.close();
}catch (Exception e){
didItWork = false;
}finally{
if (didItWork){
Dialog d = new Dialog(this);
d.setTitle("Yup");
TextView tv = new TextView(this);
tv.setText("Success");
d.setContentView(tv);
d.show();
}
}
break;
case R.id.btnView:
break;
}
}
}
MANIFEST
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sample.sqlite"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".SQLite"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.SQLITE" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
'에 의해 발생 : com.sample에서 java.lang.NullPointerException이. sqlite.SQLite.onCreate (SQLite.java:28)'... 아마도 거기에 컨텍스트를 제공하지 않았습니까? – gunar