Home Ask Login Register

Developers Planet

Your answer is one click away!

College Student February 2016

SQLiteException no such table:ItemTable while compiling: Select_id,.... from ItemTable

I've been getting this errors in my logcat for a while now. I tried a lot of things like clearing the data in my app, un-installing and re-installing my app, upgrading my DB version, I even deleted my project and created a new one but everytime i run my app i always get this error. Can someone please help me.

What I'm trying to to do is i have two buttons in an activity add item and view item, everytime i click the view item button I get this error.

When the view button is click it must show the data that I save in my database in a listview but that does not happen because my app always stopped and this show in my logcat.

This is the Image of the activity where the data should display

Here is my logcat:

02-09 05:24:23.850: E/AndroidRuntime(8037):     at com.system.inventorysystem.ViewProductItem.onCreate(ViewProductItem.java:46)
02-09 05:46:59.810: E/AndroidRuntime(13150): FATAL EXCEPTION: main
02-09 05:46:59.810: E/AndroidRuntime(13150): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.system.inventorysystem/com.system.inventorysystem.ViewProductItem}: android.database.sqlite.SQLiteException: no such table: ItemTable: , while compiling: SELECT _id, ItemDescription, ItemQuantity, ItemUnit, ItemPrice FROM ItemTable
02-09 05:46:59.810: E/AndroidRuntime(13150):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1955)
02-09 05:46:59.810: E/AndroidRuntime(13150):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
02-09 05:46:59.810: E/AndroidRuntime(13150):    at android.app.ActivityThread.access$600(ActivityThread.java:122)
02-09 05:46:59.810: E/AndroidRuntime(13150):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
02-09 05:46:59.810: E/AndroidRuntime(13150):    at android.os.Handler.dispatchMessage(Handler.java:99)
02-09 05:46:59.810: E/AndroidRuntime(1315        


laalto February 2016

You have a syntax problem in your create table. Date/Time is not a valid column name - get rid of the /.

The syntax problem is hidden because of the try-catch in SQLiteOpenHelper onCreate(). If there is a problem, onCreate() must throw an exception. Otherwise SQLiteOpenHelper thinks everything is ok.

After fixing the two problems above, either uninstall your app/clear its data or bump up the database version so that onCreate() gets called again.

Ashish Rajvanshi February 2016

Format of your create table statement is not correct.

Special symbols are not allowed in table column name

So remove "/" from Date/Time in your table column name.

it will solve the problem.

The actual problem is table is not created due to this issue and unable to throw exception because of try catch block.

Post Status

Asked in February 2016
Viewed 2,569 times
Voted 12
Answered 2 times


Leave an answer

Quote of the day: live life