在創建數據庫我總是收到此錯誤:sqlite的錯誤的Android
java.lang.IllegalArgumentException異常:版本必須> =在android.database.sqlite.SQLiteOpenHelper
版本0
任何想法如何解決這個問題。我的代碼如下
public class DatabaseHandler extends SQLiteOpenHelper{
private static final int DATABASE_VERSION = 1;
private static final String DATABASE_NAME = "Exm";
private static final String KEY_ID = "id";
private static final String KEY_USERID = "userId";
private static final String KEY_USERNAME = "userName";
private static final String KEY_LOGINSTATUS = "userLoginStatus";
public DatabaseHandler(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
public void onCreate(SQLiteDatabase db) {
String CREATE_CONTACTS_TABLE = "CREATE TABLE " + TABLE_USER + "("
+ KEY_ID + " INTEGER PRIMARY KEY ,"
+ KEY_USERID + " VARCHAR (32) ,"
+ KEY_USERNAME + " VARCHAR (50),"
+ KEY_LOGINSTATUS + " INTEGER" + ")";
db.execSQL(CREATE_CONTACTS_TABLE);
}
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("DROP TABLE IF EXISTS " + TABLE_USER);
// Create tables again
onCreate(db);
}
}
請發表日誌。 – 2013-03-18 06:59:29
threadid = 1:以未捕獲的異常退出的線程(組= 0x409961f8) 03-18 12:30:35.077:E/AndroidRuntime(1026):致命例外:主要 03-18 12:30:35.077:E/AndroidRuntime 1026):java.lang.IllegalArgumentException:版本必須> = 1,在android.database.sqlite.SQLiteOpenHelper中爲0 03-18 12:30:35.077:E/AndroidRuntime(1026):\t。(SQLiteOpenHelper.java:90) 03-18 12:30:35.077:E/AndroidRuntime(1026):\t at android.database.sqlite.SQLiteOpenHelper。 (SQLiteOpenHelper.java:69) 03-18 12:30:35.077: –
2013-03-18 07:02:53
嗨Anil M歡迎來到stackoverflow。每當你遇到一些錯誤時,在你的問題中發佈錯誤日誌,你將得到適當的迴應。 – 2013-03-18 07:04:15