0

I am new in android I connect database in my android app last time and now i am implimenting that in another project but I got these error

    12-14 23:58:07.459: E/SQLiteLog(2171): (1) no such table: Quiz
    12-14 23:58:07.459: D/AndroidRuntime(2171): Shutting down VM
    12-14 23:58:07.459: W/dalvikvm(2171): threadid=1: thread exiting with                    uncaught               exception (group=0x40a13300)
    12-14 23:58:07.509: E/AndroidRuntime(2171): FATAL EXCEPTION: main
    12-14 23:58:07.509: E/AndroidRuntime(2171): java.lang.RuntimeException: Unable to         start activity   ComponentInfo{com.example.whowantto/com.example.whowantto.play}:       android.database.sqlite.SQLiteException: no such table: Quiz (code 1): , while compiling:   SELECT Question, OptionA, OptionB, OptionC, OptionD, CorrectAnswer FROM Quiz WHERE flag=0
    12-14 23:58:07.509: E/AndroidRuntime(2171):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
    12-14 23:58:07.509: E/AndroidRuntime(2171):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
    12-14 23:58:07.509: E/AndroidRuntime(2171):     at android.app.ActivityThread.access$600(ActivityThread.java:130)
    12-14 23:58:07.509: E/AndroidRuntime(2171):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
    12-14 23:58:07.509: E/AndroidRuntime(2171):     at android.os.Handler.dispatchMessage(Handler.java:99)
    12-14 23:58:07.509: E/AndroidRuntime(2171):     at android.os.Looper.loop(Looper.java:137)
    12-14 23:58:07.509: E/AndroidRuntime(2171):     at android.app.ActivityThread.main(ActivityThread.java:4745)
    12-14 23:58:07.509: E/AndroidRuntime(2171):     at java.lang.reflect.Method.invokeNative(Native Method)
    12-14 23:58:07.509: E/AndroidRuntime(2171):     at java.lang.reflect.Method.invoke(Method.java:511)
    12-14 23:58:07.509: E/AndroidRuntime(2171):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
    12-14 23:58:07.509: E/AndroidRuntime(2171):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
    12-14 23:58:07.509: E/AndroidRuntime(2171):     at dalvik.system.NativeStart.main(Native Method)
    12-14 23:58:07.509: E/AndroidRuntime(2171): Caused by: android.database.sqlite.SQLiteException: no such table: Quiz (code 1): , while compiling: SELECT Question, OptionA, OptionB, OptionC, OptionD, CorrectAnswer FROM Quiz WHERE flag=0
    12-14 23:58:07.509: E/AndroidRuntime(2171):     at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
   12-14 23:58:07.509: E/AndroidRuntime(2171):  at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:882)
   12-14 23:58:07.509: E/AndroidRuntime(2171):  at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:493)
   12-14 23:58:07.509: E/AndroidRuntime(2171):  at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
  12-14 23:58:07.509: E/AndroidRuntime(2171):   at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
   12-14 23:58:07.509: E/AndroidRuntime(2171):  at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:37)
   12-14 23:58:07.509: E/AndroidRuntime(2171):  at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:44)
   12-14 23:58:07.509: E/AndroidRuntime(2171):  at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1314)
   12-14 23:58:07.509: E/AndroidRuntime(2171):  at android.database.sqlite.SQLiteDatabase.queryWithFactory(SQLiteDatabase.java:1161)
   12-14 23:58:07.509: E/AndroidRuntime(2171):  at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1032)
   12-14 23:58:07.509: E/AndroidRuntime(2171):  at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1238)
   12-14 23:58:07.509: E/AndroidRuntime(2171):  at com.example.whowantto.play.GetQuestion(play.java:479)
   12-14 23:58:07.509: E/AndroidRuntime(2171):  at com.example.whowantto.play.onCreate(play.java:142)
   12-14 23:58:07.509: E/AndroidRuntime(2171):  at android.app.Activity.performCreate(Activity.java:5008)
   12-14 23:58:07.509: E/AndroidRuntime(2171):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
   12-14 23:58:07.509: E/AndroidRuntime(2171):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
   12-14 23:58:07.509: E/AndroidRuntime(2171):  ... 11 more
   12-14 23:58:15.591: E/Trace(2195): error opening trace file: No such file or directory (2)

I already check Quiz table it is peresent in my databse ..Thanks in advance

5
  • how are you connecting with database post some code .
    – Abubakkar
    Dec 14, 2012 at 6:55
  • 1
    Try to uninstall your app and install it again if you changed something in your database.
    – Laura
    Dec 14, 2012 at 6:57
  • 12-14 23:58:07.509: E/AndroidRuntime(2171): Caused by: android.database.sqlite.SQLiteException: no such table: Quiz (code 1): , while compiling: SELECT Question, OptionA, OptionB, OptionC, OptionD, CorrectAnswer FROM Quiz WHERE flag=0
    – CocoNess
    Dec 14, 2012 at 6:57
  • share your Create table query.. Dec 14, 2012 at 7:10
  • I am using databasehelper file and using this code try { myDbHelper.openDataBase(); }catch (SQLException sqle) { throw sqle;} //Toast.makeText(getApplicationContext(), "UserAnswer"+level, Toast.LENGTH_LONG).show(); db = myDbHelper.getWritableDatabase(); mycursor = db.query("Quiz", new String[] { "Questions", "OptionA", "OptionB", "OptionC", "OptionD", "CorrectAnswer" },"flag"+"="+0, null, null, null, null, null); } Dec 14, 2012 at 7:57

2 Answers 2

1

The problem is that you created the database with a schema, and then you are querying it with a different schema. To fix this you can either

1) delete the database, and then create it again with the correct schema.

2) Or you can change your version number of the DB,

3) Or you can change your query to SELECT * FROM Quiz WHERE flag = 0 which will select all columns (I'm not sure if the Quiz table exists, this could be a problem)

1
  • The actual Problem Is database is showing in java file and when i check DDMS . it shows database but not table after i upload database in DDMS using push a file into device.... that's it Dec 21, 2012 at 12:12
1

Change your database name and run it. sometimes you insert extra columns in database means it will occur problem or check with query that you used.

Cursor cur = DB.rawQuery("SELECT * FROM " + table_name, null);

Hope this useful

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.