1

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.

Pierre de LESPINAY
  • 44,700
  • 57
  • 210
  • 307
Priya Raja
  • 71
  • 1
  • 7
  • Found Answer using this link http://stackoverflow.com/questions/7418849/android-sqlite-in-clause-and-placeholders – Priya Raja Dec 10 '13 at 05:03
  • well you cannot use arrays but use sets in sql to query , in your where clause . – Khay Dec 13 '13 at 13:11

0 Answers0