-1

何が起こっているのかわかりません。手がかりはありますか?

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);
}

それ以外の場合は、リクエストされたものを入れます。

4

1 に答える 1

1

これは、テーブル名が であるためですStories Table。のようなものに変更しStoriesTableます。もちろん、列名も変更します。

于 2012-11-05T19:03:21.220 に答える