public class DBhandle {
private static final String DATABASE_NAME = "restaurantdatabase";
private static final int DATABASE_VERSION = 1;
final Context context;
private SQLiteDatabase ourDatabase;
//table name
private static final String LOGIN_TABLE_NAME = "Login";
//login table column name
public static final String KEY_ROWID = "ID";
public static final String A_NAME = "admin_name";
public static final String A_PHONE = "admin_phone";
DatabaseHelper dbHelper;
public static class DatabaseHelper extends SQLiteOpenHelper {
public DatabaseHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL("CREATE TABLE " + LOGIN_TABLE_NAME + " (" + KEY_ROWID
+ " INTEGER PRIMARY KEY AUTOINCREMENT, " + A_NAME
+ " TEXT NOT NULL, " + A_PHONE + " TEXT NOT NULL);"
);
}
public long insertEntry(String userName, String password) {
//SQLiteDatabase db = this.getWritableDatabase();
ContentValues newValues = new ContentValues();
// Assign values for each row.
newValues.put("A_NAME", userName);
newValues.put("A_PHONE", password);
// Insert the row into your table
return ourDatabase.insert(LOGIN_TABLE_NAME, null, newValues);
//Toast.makeText(context, "Reminder Is Successfully Saved", Toast.LENGTH_LONG).show();
}
}
}
我試圖將數據插入我收到一個數據庫(?,?)但以下情況除外:表(登錄)沒有名爲(A_NAME)(代碼1)列:,在編譯:INSERT INTO登錄(A_NAME,A_PHONE)VALUES
android.database.sqlite.SQLiteException: table Login has no column named A_NAME (code 1): , while compiling: INSERT INTO Login(A_NAME,A_PHONE) VALUES (?,?).
只需移除(「)鑰匙周圍的雙人牀。 –