I need to fetch rows from database where column named "Uid" matches a few options. Since the number or arguments is dynamic, I need to pass it the arguments as array.
public Cursor Topicsname(List list) {
SQLiteDatabase sq = this.getReadableDatabase();
String where = "";
for (int i=0; i<list.size(); i++) {
where = where+"Uid"+" ="+list.get(i).toString()+"";
if (i!=(list.size()-1)) where=where+" or ";
}
Cursor cursor = sq.query("Topics", new String[] {"Main_Topics"},
where, null, null, null, null);
return cursor;
}
But I get row count as 0. Here "Topics"- Table Name, "Main_Topics" -Column name I need to fetch, "Uid" column name that matches the list value.