我正在使用sqlite数据库....应用程序正在使用2.3及更高版本...当我尝试在2.2中运行时......我收到了类似的错误....
E/Database(2476):sqlite3_open_v2("/data/data/com.android.packagename/databases/dump.sqlite", &handle, 1, NULL) failed
数据库有一些问题。
当我尝试在2.2中运行我的应用程序时。 我的logcat显示
E/Database(2476):sqlite3_open_v2("/data/data/com.android.canadaQbank/databases/dump.sqlite", &handle, 1, NULL) failed
D/asset(2476): Data exceeds UNCOMPRESS_DATA_MAX (4594688 vs 1048576)
D/AndroidRuntime(2476): Shutting down VM
W/dalvikvm(2476): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
D/dalvikvm(2476): GC_FOR_MALLOC freed 6256 objects / 356848 bytes in 165ms
E/AndroidRuntime(2476): FATAL EXCEPTION: main
E/AndroidRuntime(2476): java.lang.Error: Error copying database
E/AndroidRuntime(2476): at com.android.canadaQbank.DBAdapter.createDataBase(DBAdapter.java:83)
E/AndroidRuntime(2476): at com.android.canadaQbank.Select.getUsers(Select.java:110)
E/AndroidRuntime(2476): at com.android.canadaQbank.Select.onCreate(Select.java:92)
E/AndroidRuntime(2476): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
E/AndroidRuntime(2476): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
E/AndroidRuntime(2476): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
E/AndroidRuntime(2476): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
E/AndroidRuntime(2476): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
E/AndroidRuntime(2476): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(2476): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime(2476): at android.app.ActivityThread.main(ActivityThread.java:4627)
E/AndroidRuntime(2476): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(2476): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime(2476): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
E/AndroidRuntime(2476): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
E/AndroidRuntime(2476): at dalvik.system.NativeStart.main(Native Method)
请有人帮忙......
答案 0 :(得分:12)
我也有同样的问题sqlite3_open_v2失败
但在搜索此问题后,我发现了这个link,我根据此链接修改了我的代码,修改后的代码如下所示:
public boolean databaseExist()
{
File dbFile = new File(DB_PATH + DB_NAME);
return dbFile.exists();
}
希望这也有助于解决您的问题。 :)
答案 1 :(得分:1)
private boolean checkDataBase(){
SQLiteDatabase checkDB = null;
try{
String myPath = DB_PATH + DB_NAME;
checkDB = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY);
}catch(SQLiteException e){
//database does't exist yet.
}
if(checkDB != null){
checkDB.close();
}
return checkDB != null ? true : false;
}
你可以尝试一下,希望这会对你有所帮助。还要检查Android 2.2支持的dadabase版本。一切顺利。