我試圖將數據添加到以下的助手類,但我得到了'沒有這樣的表'錯誤。如何解決在Android Sqlite沒有這樣的表錯誤
如果我們使用普通的SQL查詢,它開始工作。但是這種類型的查詢不起作用。如何編寫這些類型的查詢,請解釋語法!
static class EmpHelper extends SQLiteOpenHelper{
private static final String DATABASE_NAME = "empdatabase";
private static final String TABLE_NAME = "emptable";
private static final int DATABASE_VERSION = 2;
private static final String UID = "_id";
private static final String NAME = "Name";
private static final String PASSWORD = "Password";
private static final String CREATE_TABLE = "CREATE TABLE" + TABLE_NAME
+ "("+UID+ " INTEGER PRIMARY KEY AUTOINCREMENT," + NAME
+ " VARCHAR(255)," + PASSWORD + "VARCHAR2(255)"+")";
private static final String DROP_TABLE = "DROP TABLE IF EXISTS"
+ TABLE_NAME;
private Context context;
public EmpHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
this.context = context;
Message.message(context, "constructor called");
}
@Override
public void onCreate(SQLiteDatabase db) {
// TODO Auto-generated method stub
try {
db.execSQL(CREATE_TABLE);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}