Categories
android database sqlite

Inappropiate search through sqlite database from android

This query seems to work fine:

public Cursor getOneWine(long id) {
return database.query("vino", null, "_id=" + id, null,
null, null, null);
}

But when I try to change "_id"+id to "name="+name it does not work! also tried this:

public Cursor getSearchWine(String name) {
return database.query("vino", new String[] {"_id", "name"}, "name="+name, null,
null, null, "name");
}

which is working well when I want a cursor from all wines.

public Cursor getAllWines() {
return database.query("vino", new String[] {"_id", "name"}, null, null,
null, null, "name");
}

Also checked the Android documentation but didn’t find a solution.