After trying to get a text from the database i got this error:
12-21 09:54:10.948: E/AndroidRuntime(25745): FATAL EXCEPTION: main
12-21 09:54:10.948: E/AndroidRuntime(25745): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ggservice.democracy/com.ggservice.democracy.sondaggioActivity}: android.database.sqlite.SQLiteException: near "=": syntax error: , while compiling: SELECT _id, preferita, nome FROM sondaggi WHERE _id=
this is the call:
Cursor values = datasource.getDomanda(strcategory );
if (values.moveToFirst()) // data?
System.out.println(values.getString(values.getColumnIndex("domanda")));
values.close();
And it calls this:
public Cursor getDomanda(String id) {
List<sondaggi> domande = new ArrayList<sondaggi>();
Cursor cursor = database.query(MySQLiteHelper.TABLE_SONDAGGI,
allCategorieColumns, MySQLiteHelper.COLUMN_ID + "=", new String[] { id }, null, null, null);
cursor.moveToFirst();
while (!cursor.isAfterLast()) {
sondaggi sondaggio = cursorToSondaggi(cursor);
domande.add(sondaggio);
cursor.moveToNext();
}
return cursor;
}
the id seams empty, but i know there is a value there, i have tested the variable passage. i mean, if i Toast the strcategory it return the right value.
Chnage
Cursor cursor = database.query(MySQLiteHelper.TABLE_SONDAGGI,
allCategorieColumns,
MySQLiteHelper.COLUMN_ID + "=",
new String[] { id }, null, null, null);
to
Cursor cursor = database.query(MySQLiteHelper.TABLE_SONDAGGI,
allCategorieColumns,
MySQLiteHelper.COLUMN_ID + "=?",
new String[] { id }, null, null, null);