I'm trying to select password from a database where name = the name I sent in the parameters of the method. I'm writing all the names of the database so the name is 100% inside the database.
But I get the following error: android.database.sqlite.SQLiteException: no such column: kristofer (code 1): , while compiling: SELECT * FROM login WHERE _name = kristofer
public String databasePassword(String name){
String dbString = "";
SQLiteDatabase db = getWritableDatabase();
String query = "SELECT * FROM " + TABLE_LOGIN + " WHERE "+COLUMN_NAME + " = " + name;
//Cursor point to a location in your results
Cursor c = db.rawQuery(query, null);
//Move to the first row in your results
c.moveToFirst();
while(!c.isAfterLast()){
if(c.getString(c.getColumnIndex("_password"))!=null){ //Loop through every row in a database
dbString += c.getString(c.getColumnIndex("_password"));
dbString += "\n";
}
c.moveToNext();
}
db.close();
return dbString;
}