dimanche 8 mai 2016

android.database.sqlite.SQLiteException: no such table: USER_DATA_TABLE (code 1): , while compiling: SELECT * FROM USER_DATA_TABLE WHERE id=? LIMIT 1

I'm facing a very strange error during running android app in Android Studio on emulator. Error is pasted below.

I'm not using SQLite for db. I'm using Shared performances. There is no reference to USER_DATA_TABLE or SQLite in the code.

The only place where I could see reference to USER_DATA_TABLE & SQLite is in /build/generated/mockable-android-23.jar file which is obviously generated by the build process. I deleted entire build folder before building the app and running.

Can any of you experts give me some clue on how to fix it?

The code snippet which access SugarORM is this:

   public void redrawNavMenu() {
    UserDataTable user = UserDataTable.findById(UserDataTable.class, 1L);

findById method used is in SugarORM

public static <T extends SugarRecord<?>> T findById(Class<T> type, Long id) {
    List<T> list = find( type, "id=?", new String[]{String.valueOf(id)}, null, null, "1");
    if (list.isEmpty()) return null;
    return list.get(0);
}

I'm lost here. So where does USER_DATA_TABLE is accessed from if it's not anywhere in the code at all?

Log:

java.lang.RuntimeException: Unable to start activity ComponentInfo{http://ift.tt/23zI0uk}: android.database.sqlite.SQLiteException: no such table: USER_DATA_TABLE (code 1): , while compiling: SELECT * FROM USER_DATA_TABLE WHERE id=? LIMIT 1
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
        at android.app.ActivityThread.-wrap11(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:148)
        at android.app.ActivityThread.main(ActivityThread.java:5417)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
     Caused by: android.database.sqlite.SQLiteException: no such table: USER_DATA_TABLE (code 1): , while compiling: SELECT * FROM USER_DATA_TABLE WHERE id=? LIMIT 1
        at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
        at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:887)
        at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:498)
        at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
        at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
        at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:37)
        at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:44)
        at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1316)
        at android.database.sqlite.SQLiteDatabase.queryWithFactory(SQLiteDatabase.java:1163)
        at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1034)
        at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1240)
        at com.orm.SugarRecord.find(SugarRecord.java:208)
        at com.orm.SugarRecord.findById(SugarRecord.java:138)
        at com.matt.quiz.activities.QuizActivity.redrawNavMenu(QuizActivity.java:461)
        at com.matt.quiz.activities.QuizActivity.onCreate(QuizActivity.java:194)
        at android.app.Activity.performCreate(Activity.java:6237)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
        at android.app.ActivityThread.-wrap11(ActivityThread.java) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:148) 
        at android.app.ActivityThread.main(ActivityThread.java:5417) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 

Aucun commentaire:

Enregistrer un commentaire