lundi 27 juillet 2015

Android .qurey does not get the data from db when I used where clause

I used .query to select some specific row from SQLite db table but when I used the where clause it does not retrieve data, and if I use null instead of where clause, it retrieve the last row.

public String[] getAllData(){

        hoqooqdb = this.getReadableDatabase();

        String[] columns = new String[] {"_id", "title", "content"};
        Cursor cursor = hoqooqdb.query("unmanshor", columns, "_id = 1", null, null, null, null);

        String[] result = new String[2];

        while (cursor.moveToNext()){

            int iTitle = cursor.getColumnIndex("title");
            int iContent = cursor.getColumnIndex("content");

            result[0] = cursor.getString(iTitle);
            result[1] = cursor.getString(iContent);
        }
        return result;
    }

Aucun commentaire:

Enregistrer un commentaire