1
次のコマンドを実行するとエラーが発生します。その前にアプリケーションをアンインストールして再インストールする前にクエリが以前の更新で機能していたため、CREATE INDEX
SQLite:単一のSQLコマンドで列とインデックスを作成する方法
private static final String DATABASE_NAME = "db_name.db";
private static final int DATABASE_VERSION = 1;
private static final String CREATE_TABLE_MESSAGES = "create table messages"
+ "("
+ "_id" + " integer primary key autoincrement, "
+ "message_id" + " text not null, "
+ "sender" + " text not null, "
+ "recipient" + " text DEFAULT NA, "
+ "message" + " text not null, "
+ "shared" + " text not null, "
+ "sent" + " Boolean DEFAULT false, "
+ "delivered" + " Boolean DEFAULT false, "
+ "read" + " Boolean DEFAULT false, "
+ "hasobject" + " Boolean DEFAULT false, "
///object//
+ "object" + " text DEFAULT NA, "
///meta///
+ "deviceid" + " text DEFAULT NA, "
+ "modified_time" + " integer not null, "
+ "time" + " integer not null, "
+ "CREATE INDEX IF NOT EXISTS shared_index on messages(shared),"
+ "created_time" + " integer not null " + ")";
public DatabaseHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL(CREATE_TABLE_MESSAGES);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
if (newVersion > oldVersion) {
// db.execSQL("CREATE INDEX IF NOT EXISTS shared_index on messages(shared);");
}
}
@ロットワン、それはそんなことは考えていない。あなたのコメントを答えとして書いてください。 – Relm