Inside of my Input.java file I have
public class Input {
private int _id;
private String _username;
public Input(){
}
public Input(String username){
this._username = username;
}
public void set_id(int _id) {
this._id = _id;
}
public void set_username(String _username) {
this._username = _username;
}
public int get_id() {
return _id;
}
public String get_username() {
return _username;
}
}
and inside of my DBHandler.java
public class DBHandler extends SQLiteOpenHelper {
private static final int DATABASE_VERSION = 1;
private static final String DATABASE_NAME = "input.db";
public static final String TABLE_INPUT = "input";
public static final String COLUMN_ID = "_id";
public static final String COLUMN_USERNAME = "username";
public DBHandler(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
super(context, DATABASE_NAME, factory, DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
String query = "CREATE TABLE " + TABLE_INPUT + "(" +
COLUMN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT " +
COLUMN_USERNAME + " TEXT " +
");";
db.execSQL(query);
}
Whenever I try to execute this, I get the error:
Caused by: android.database.sqlite.SQLiteException: near "username": syntax error (code 1): , while compiling: CREATE TABLE input(_id INTEGER PRIMARY KEY AUTOINCREMENT username TEXT );
What exactly am I doing wrong?
Aucun commentaire:
Enregistrer un commentaire