我有一个例外:
android.database.sqlite.SQLiteException: near "Login": syntax error (code 1): , while compiling: Login
当我尝试创建新数据库时。
那是我的MainActivity代码,我在其中调用createDataBase:
public class CreateSQLite extends AsyncTask<Integer, String, Integer> {
ProgressDialog progress;
Context context;
public CreateSQLite(Context context) {
this.context = context;
}
protected void onPreExecute() {
}
protected Integer doInBackground(Integer... paramss) {
SqliteHelper dbHelper = new SqliteHelper(MainActivity.this);
mDb = openOrCreateDatabase("FManagement.db", Context.MODE_PRIVATE, null);
dbHelper.onUpgrade(mDb, 4, 5);
return 0;
}
protected void onPostExecute(Integer result) {
if(progress.isShowing())
progress.dismiss();
}
}
这是我的登录表:
public class LoginTable {
public static final String TABLE_LOGIN = "Login";
public static final String COL_USER_ID = "user";
public static final String COL_PASSWORD = "password";
public static final String COL_REMEMBER_PASSWORD = "remember_password";
public static final String COL_LAST_ACCESS = "last_access";
public static final String DB_LOGIN = "CREATE TABLE " + TABLE_LOGIN + "("
+ COL_USER_ID + " TEXT PRIMARY KEY, "
+ COL_PASSWORD + " TEXT, "
+ COL_REMEMBER_PASSWORD + " TEXT, "
+ COL_LAST_ACCESS + " TEXT " + ")";
}
那是我的助手数据库:
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL(LoginTable.TABLE_LOGIN);
db.execSQL(UserTable.TABLE_USER);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("DROP TABLE IF EXISTS " + LoginTable.TABLE_LOGIN);
db.execSQL("DROP TABLE IF EXISTS " + UserTable.TABLE_USER);
onCreate(db);
}
我不太理解该异常,我做错了什么吗?
有人可以帮助我吗?
谢谢! o /