0
11-20 11:20:37.147    4117-4117/com.example.ilhamsabar.cobadiet E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: com.example.ilhamsabar.cobadiet, PID: 4117
    android.database.sqlite.SQLiteException: no such table: dietocd (code 1): , while compiling: SELECT * FROM dietocd
            at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
            at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:889)
            at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:500)
            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.rawQuery(SQLiteDatabase.java:1255)
            at com.example.ilhamsabar.cobadiet.LayoutOcd.onCreateView(LayoutOcd.java:46)
            at android.support.v4.app.Fragment.performCreateView(Fragment.java:1789)
            at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:955)
            at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1138)
            at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:740)
            at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1501)
            at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:458)
            at android.os.Handler.handleCallback(Handler.java:739)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5234)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:909)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:704)
Dhaval Patel
  • 10,119
  • 5
  • 43
  • 46
  • It will help if you share more details about the error and why you think it might have occurred. Copy-pasting the error seldom works. – Balwinder Singh Nov 20 '15 at 03:47

1 Answers1

1

First, you should give more details about your error. Some code, your db structure, if it's encrypted or not, etc.

Then, your error is no such table.

This error, when you are SURE that the table's name and the request are written properly, typically means that you are working on an empty DB or that a table is missing because the creation of this one failed for some reasons.

For example I'm sure that there is the first access you make to the database right for this table? If you select something you will see that you have no table or data.

This error come from an error while creating the db. Basically what most of the apps are doing is creating an empty db in the device and then copying the content of the one provided with the app, in your asset folder, to the empty one. However if there is an error in the process the copy is cancelled and your database remains empty. If you create all the db programmatically it should mean that the table creation failed.

Try to Select * on your db to see if there is content or not, then check your db creation process. You'll probably find out that one of your tables is missing, or that the creation of the db failed.

Virthuss
  • 3,142
  • 1
  • 21
  • 39