-1
我不知道發生了什麼。任何線索?SQLite onCreate異常
11-05 18:02:01.195: D/dalvikvm(641): Not late-enabling CheckJNI (already on)
11-05 18:02:01.595: E/Trace(641): error opening trace file: No such file or directory (2)
11-05 18:02:01.907: E/SQLiteLog(641): (1) near "Table": syntax error
11-05 18:02:01.915: D/AndroidRuntime(641): Shutting down VM
11-05 18:02:01.915: W/dalvikvm(641): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
11-05 18:02:01.925: E/AndroidRuntime(641): FATAL EXCEPTION: main
11-05 18:02:01.925: E/AndroidRuntime(641): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.cookbook.adiel/com.cookbook.adiel.MainActivity}: android.database.sqlite.SQLiteException: near "Table": syntax error (code 1): , while compiling: CREATE TABLE Stories Table(row id INTEGER PRIMARY KEY,Story name TEXT,Recipe ingredients TEXT,Clean recipe TEXT,)
11-05 18:02:01.925: E/AndroidRuntime(641): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
11-05 18:02:01.925: E/AndroidRuntime(641): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
11-05 18:02:01.925: E/AndroidRuntime(641): at android.app.ActivityThread.access$600(ActivityThread.java:130)
11-05 18:02:01.925: E/AndroidRuntime(641): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
11-05 18:02:01.925: E/AndroidRuntime(641): at android.os.Handler.dispatchMessage(Handler.java:99)
11-05 18:02:01.925: E/AndroidRuntime(641): at android.os.Looper.loop(Looper.java:137)
11-05 18:02:01.925: E/AndroidRuntime(641): at android.app.ActivityThread.main(ActivityThread.java:4745)
11-05 18:02:01.925: E/AndroidRuntime(641): at java.lang.reflect.Method.invokeNative(Native Method)
11-05 18:02:01.925: E/AndroidRuntime(641): at java.lang.reflect.Method.invoke(Method.java:511)
11-05 18:02:01.925: E/AndroidRuntime(641): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
11-05 18:02:01.925: E/AndroidRuntime(641): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
11-05 18:02:01.925: E/AndroidRuntime(641): at dalvik.system.NativeStart.main(Native Method)
11-05 18:02:01.925: E/AndroidRuntime(641): Caused by: android.database.sqlite.SQLiteException: near "Table": syntax error (code 1): , while compiling: CREATE TABLE Stories Table(row id INTEGER PRIMARY KEY,Story name TEXT,Recipe ingredients TEXT,Clean recipe TEXT,)
11-05 18:02:01.925: E/AndroidRuntime(641): at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
11-05 18:02:01.925: E/AndroidRuntime(641): at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:882)
11-05 18:02:01.925: E/AndroidRuntime(641): at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:493)
11-05 18:02:01.925: E/AndroidRuntime(641): at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
11-05 18:02:01.925: E/AndroidRuntime(641): at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
11-05 18:02:01.925: E/AndroidRuntime(641): at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
11-05 18:02:01.925: E/AndroidRuntime(641): at android.database.sqlite.SQLiteDatabase.executeSql(SQLiteDatabase.java:1663)
11-05 18:02:01.925: E/AndroidRuntime(641): at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1594)
11-05 18:02:01.925: E/AndroidRuntime(641): at com.cookbook.adiel.StoryDatabaseHandler.onCreate(StoryDatabaseHandler.java:40)
11-05 18:02:01.925: E/AndroidRuntime(641): at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:252)
11-05 18:02:01.925: E/AndroidRuntime(641): at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:164)
11-05 18:02:01.925: E/AndroidRuntime(641): at com.cookbook.adiel.StoryDatabaseHandler.addStory(StoryDatabaseHandler.java:55)
11-05 18:02:01.925: E/AndroidRuntime(641): at com.cookbook.adiel.MainActivity.onCreate(MainActivity.java:50)
11-05 18:02:01.925: E/AndroidRuntime(641): at android.app.Activity.performCreate(Activity.java:5008)
11-05 18:02:01.925: E/AndroidRuntime(641): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
11-05 18:02:01.925: E/AndroidRuntime(641): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
11-05 18:02:01.925: E/AndroidRuntime(641): ... 11 more
我猜它與onCreate方法有關,所以在這裏。 數據庫處理器onCreate方法:
private static final String DATABASE_TABLE = "Stories Table";
// table column names
private static final String KEY_ROWID = "row id";
private static final String KEY_STORYNAME = "Story name";
private static final String KEY_INGREDIENTS = "Recipe ingredients";
private static final String KEY_RECIPE = "Clean recipe";
public StoryDatabaseHandler(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
// Creating table
@Override
public void onCreate(SQLiteDatabase db) {
// TODO Auto-generated method stub
String CREATE_STORIES_TABLE = "CREATE TABLE " + DATABASE_TABLE + "("
+ KEY_ROWID + " INTEGER PRIMARY KEY," + KEY_STORYNAME
+ " TEXT," + KEY_INGREDIENTS + " TEXT," + KEY_RECIPE + " TEXT,"
+ ")";
db.execSQL(CREATE_STORIES_TABLE);
}
如果是別的東西,我會把要求什麼。
也更改列名稱並從語句中刪除最後一個逗號。 –
現在它不給我任何錯誤,它只是帖子 「11-05 19:23:09.951:D/dalvikvm(640):GC_CONCURRENT釋放313K,6%免費6631K/7047K,暫停29ms + 21ms,總共105ms」 種類的消息,無限地 – user1772785
所以,我想它的工作:) –