Search code examples
androidsqliteandroid-sqlitegenymotion

E/SQLiteLog: (14) cannot open file at line 28372 of [00bb9c9ce4]


I'm having trouble while storing data in the SqlLite on Genymotion Emulator , Some data are being inserted and crash in middle with the following error

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) 

And my SQLiteOpenHelper Constructor is:

public MyAppSQLiteOpenHelper(Context context) {
  super(context, DATABASE_NAME, null, DATABASE_VERSION);
}

And I have the following Override methods :

@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 
}

And my minimum SDKVersion is 14 And I have this permission in the manifest

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

I look forward to hear from you , Thanks


Solution

  • The problem was solved after changing the query from this SELECT COUNT(*) FROM User WHERE id = ?] to SELECT * FROM User WHERE id = ?] , The solution seems wild but I worked after changing that query, If you have similar problem try to change you query