Caused by: android.database.sqlite.SQLiteException: near "CREATE_TABLE": syntax error (code 1): , while compiling: CREATE_TABLE users(username TEXT, password TEXT );
public class MyDB extends SQLiteOpenHelper {
private static final int DATABASE_VERSION = 1;
private static final String DATABASE_NAME = "users.db";
private static final String TABLE_USERS = "users";
private static final String COLUMN_ID = "_id";
private static final String COLUMN_USERNAME = "username";
private static final String COLUMN_PASSWORD = "password";
public MyDB(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
super(context, DATABASE_NAME, factory, DATABASE_VERSION);
}
// called when database is first created
@Override
public void onCreate(SQLiteDatabase db) {
String query = "CREATE_TABLE " + TABLE_USERS + "(" +
// COLUMN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL DEFAULT 1" +
COLUMN_USERNAME + " TEXT, " +
COLUMN_PASSWORD + " TEXT " +
");";
db.execSQL(query);
}
Aucun commentaire:
Enregistrer un commentaire