Regarding fetching data from database in android application
I am developing an android application in which I have created a database named HeadShop. When I run the code it is crashing. Below is the crash report:
09-02 14:29:36.441: ERROR/AndroidRuntime(14984): java.lang.RuntimeException:
Unable to start activity ComponentInfo{com.redorange.database/com.redorange.database.HeadshopDatabaseActivity}: android.database.sqlite.SQLiteException: table HeadTable already exists: create 开发者_JAVA技巧table HeadTable( _id integer primary key autoincrement, Name text not null, Grade text not null, Description text not null);
09-02 14:29:36.441: ERROR/AndroidRuntime(14984): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1622)
09-02 14:29:36.441: ERROR/AndroidRuntime(14984): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1638)
Can anyone help me in this regard?
I have coded acc to sqlite example.
Its crashing because you are trying to create a table that already exists. Modify your create table query.
CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name
http://dev.mysql.com/doc/refman/5.1/en/create-table.html
精彩评论