我嘗試在數據庫中創建三個表,但它僅創建tbl_alarms,tbl_bookmarks和android_metadata。爲什麼我無法創建tbl_locationfrommap?創建sqlite的表在Android中
SQLiteDatabase db;
db = openOrCreateDatabase("Informations.db", SQLiteDatabase.CREATE_IF_NECESSARY, null);
db.setVersion(1);
db.setLocale(Locale.getDefault());
db.setLockingEnabled(true);
Cursor cursor=db.rawQuery("select DISTINCT tbl_name from sqlite_master where tbl_name = 'tbl_alarms'", null);
if(cursor.getCount()==0) {
final String CREATE_TABLE_ALARMS = "CREATE TABLE tbl_alarms (" +
"alarmName TEXT PRIMARY KEY," +
" distance INTEGER,
ringtone TEXT,
vibrate INTEGER,
latitude INTEGER,
longitude INTEGER,
note TEXT,
alarmTime LONG,
alarmSnoozeTime LONG);";
final String CREATE_TABLE_BOOKMARKS = "CREATE TABLE tbl_bookmarks (" +
"bookmarkName TEXT PRIMARY KEY," +
"latitude INTEGER,
longitude INTEGER);";
final String CREATE_TABLE_MAPLOCATION = "CREATE TABLE tbl_locationfrommap (" +
"latitude INTEGER PRIMARY KEY"+
" , longitude INTEGER PRIMARY KEY);";
db.execSQL(CREATE_TABLE_ALARMS);
db.execSQL(CREATE_TABLE_BOOKMARKS);
db.execSQL(CREATE_TABLE_MAPLOCATION);
}
可以有每表僅1主鍵。 – AndroidGuy