我正在尝试从本地数据库获取数据但是每当屏幕打开时我都会收到类似
的错误08-16 03:54:40.900: E/AndroidRuntime(13934): FATAL EXCEPTION: main
08-16 03:54:40.900: E/AndroidRuntime(13934): Process: com.appworld.detail, PID: 13934
08-16 03:54:40.900: E/AndroidRuntime(13934): java.lang.Error: Unable to create database
08-16 03:54:40.900: E/AndroidRuntime(13934): at com.appworld.detail.Name.onCreate(BankName.java:47)
08-16 03:54:40.900: E/AndroidRuntime(13934): at android.app.Activity.performCreate(Activity.java:5231)
08-16 03:54:40.900: E/AndroidRuntime(13934): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
08-16 03:54:40.900: E/AndroidRuntime(13934): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
08-16 03:54:40.900: E/AndroidRuntime(13934): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
08-16 03:54:40.900: E/AndroidRuntime(13934): at android.app.ActivityThread.access$800(ActivityThread.java:135)
08-16 03:54:40.900: E/AndroidRuntime(13934): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
08-16 03:54:40.900: E/AndroidRuntime(13934): at android.os.Handler.dispatchMessage(Handler.java:102)
08-16 03:54:40.900: E/AndroidRuntime(13934): at android.os.Looper.loop(Looper.java:136)
08-16 03:54:40.900: E/AndroidRuntime(13934): at android.app.ActivityThread.main(ActivityThread.java:5017)
08-16 03:54:40.900: E/AndroidRuntime(13934): at java.lang.reflect.Method.invokeNative(Native Method)
08-16 03:54:40.900: E/AndroidRuntime(13934): at java.lang.reflect.Method.invoke(Method.java:515)
08-16 03:54:40.900: E/AndroidRuntime(13934): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
08-16 03:54:40.900: E/AndroidRuntime(13934): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
08-16 03:54:40.900: E/AndroidRuntime(13934): at dalvik.system.NativeStart.main(Native Method)
我的代码如下。
DatabaseOpenHelper databaseOpenHelper = new DatabaseOpenHelper(BankName.this);
databaseOpenHelper = new DatabaseOpenHelper(this);
try {
databaseOpenHelper.createDataBase();
try {
databaseOpenHelper.openDataBase();
List<String> labels = databaseOpenHelper.getAOne();
databaseOpenHelper.close();
this.adapter = new ArrayAdapter<String>(this, R.layout.site_list_row, R.id.title , labels);
setListAdapter(this.adapter);
getListView().setChoiceMode(2);
this.edtSearch.addTextChangedListener(new textListener());
} catch (SQLException e) {
throw e;
}
} catch (IOException e) {
throw new Error("Unable to create database");
}
并在databaseopenhelper中:
public void createDataBase() throws IOException {
getReadableDatabase();
close();
copyDataBase();
}
我不知道我的代码有什么问题......任何帮助都会受到赞赏......