我在 Genymotion 模拟器上的SqlLite中存储数据时出现问题,有些数据正在插入并在中间崩溃并出现以下错误
E/SQLiteLog: (14) cannot open file at line 28372 of [00bb9c9ce4]
12-10 17:52:40.887 24250-24328/? E/SQLiteLog: (14) os_unix.c:28372: (24) open(/data/data/com.myapp.myapp/databases) -
E/SQLiteLog: (14) cannot open file at line 30174 of [00bb9c9ce4]
E/SQLiteLog: (14) os_unix.c:30174: (24) open(/data/data/com.myapp.myapp/databases/myapp.db-journal) -
E/SQLiteLog: (14) cannot open file at line 30174 of [00bb9c9ce4]
782/? E/SQLiteLog: (14) os_unix.c:30174: (24) open(/data/data/com.myapp.v/databases/myapp.db-journal) -
E/SQLiteLog: (14) statement aborts at 10: [SELECT COUNT(*) FROM User WHERE id = ?] unable to open database file
E/SQLiteQuery: exception: unable to open database file (code 14); query: SELECT COUNT(*) FROM User WHERE id = ?
D/url error: android.database.sqlite.SQLiteCantOpenDatabaseException: unable to open database file (code 14)
我的SQLiteOpenHelper
构造函数是:
public MyAppSQLiteOpenHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
我有以下覆盖方法:
@Override
public void onOpen(SQLiteDatabase db) {
super.onOpen(db);
db.execSQL("PRAGMA FOREIGN_KEYS=ON ");
}
@Override
public void onCreate(SQLiteDatabase db) {
//My create tables script
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
//Dropt tables script
}
我的最低SDKVersion是14 我在清单中有这个许可
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
我期待收到你的回复,谢谢
答案 0 :(得分:0)
将查询从此SELECT COUNT(*) FROM User WHERE id = ?]
更改为SELECT * FROM User WHERE id = ?]
后问题得以解决,解决方案似乎很疯狂,但我在更改查询后工作,如果您遇到类似问题,请尝试更改查询