Я добавляю нового пользователя, но когда я пытаюсь войти в систему, это приводит к сбою моего приложения.Он говорит мне, что нет колонки «имя».Любая помощь будет принята с благодарностью.Вот мой код:
public void onCreate(SQLiteDatabase db) {
// TODO Auto-generated method stub
db.execSQL(
"create table users " +
"(id integer primary key, name text,password text,age integer)"
);
db.execSQL(
"create table tasks " +
"(id integer primary key, name text, agemin integer,agemax integer,time integer)"
);
}
public boolean insertUser (String name, String password, int age) {
SQLiteDatabase db = this.getWritableDatabase();
ContentValues contentValues = new ContentValues();
contentValues.put("name", name);
contentValues.put("password", password);
contentValues.put("age", age);
db.insert("users", null, contentValues);
return true;
}
public boolean checkPassword(String name, String password) {
int id = getUserIDByName(name);
SQLiteDatabase db = this.getReadableDatabase();
Cursor res = db.rawQuery( "select password from users where id="+id+"", null );
String pass = res.getString(1);
return (password.equals(pass));
}
public int getUserIDByName(String name) {
SQLiteDatabase db = this.getReadableDatabase();
Cursor res = db.rawQuery( "select id from users where name="+name+"", null );
int id = res.getInt(1);
return id;