1つのテーブルでシンプルなデータベースを作成し、ActivityAndroidをORMとして使用しようとしています。しかし、プロジェクトを開始した後、私はそのようなエラーがあります:
03-30 17:41:01.379: INFO/Database(345): sqlite returned: error code = 1, msg = duplicate column name: id
03-30 17:41:01.379: ERROR/Database(345): Failure 1 (duplicate column name: id) on 0x1e2140 when preparing 'CREATE TABLE IF NOT EXISTS Quote (Id INTEGER PRIMARY KEY AUTOINCREMENT, author TEXT, id INTEGER, text TEXT);'.
03-30 17:41:01.398: DEBUG/AndroidRuntime(345): Shutting down VM
03-30 17:41:01.398: WARN/dalvikvm(345): threadid=1: thread exiting with uncaught exception (group=0x40015560)
03-30 17:41:01.418: ERROR/AndroidRuntime(345): FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to create application com.activeandroid.app.Application: android.database.sqlite.SQLiteException: duplicate column name: id: CREATE TABLE IF NOT EXISTS Quote (Id INTEGER PRIMARY KEY AUTOINCREMENT, author TEXT, id INTEGER, text TEXT);
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3275)
at android.app.ActivityThread.access$2200(ActivityThread.java:117)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:969)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:3683)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.database.sqlite.SQLiteException: duplicate column name: id: CREATE TABLE IF NOT EXISTS Quote (Id INTEGER PRIMARY KEY AUTOINCREMENT, author TEXT, id INTEGER, text TEXT);
at android.database.sqlite.SQLiteDatabase.native_execSQL(Native Method)
at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1763)
at com.activeandroid.DatabaseHelper.createTable(DatabaseHelper.java:138)
at com.activeandroid.DatabaseHelper.onCreate(DatabaseHelper.java:51)
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:126)
at com.activeandroid.Registry.openDatabase(Registry.java:149)
at com.activeandroid.Registry.initialize(Registry.java:107)
at com.activeandroid.ActiveAndroid.initialize(ActiveAndroid.java:8)
at com.activeandroid.app.Application.onCreate(Application.java:9)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:969)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3272)
... 10 more
私はどこにもそのようなコードを持っていません..私のSQLコード:
public class QuoteDatabaseHandler extends SQLiteOpenHelper {
private static final int DATABASE_VERSION = 1;
private static final String DATABASE_NAME = "DB1";
private static final String TABLE_NAME = "Quote";
private static final String KEY_ID = "id";
private static final String KEY_TEXT = "text";
private static final String KEY_AUTHOR = "author";
public QuoteDatabaseHandler(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
String createQuery = "CREATE TABLE " + TABLE_NAME +
"(" +
KEY_ID + " INTEGER PRIMARY KEY," +
KEY_TEXT + " TEXT," +
KEY_AUTHOR + " TEXT" +
")";
db.execSQL(createQuery);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
onCreate(db);
}
}
なぜそうなのか、いくつかの提案はありますか?私はそれをデバッグしようとしていましたが、dbを作成する前に失敗しました..