samedi 10 octobre 2015

Unable to fetch data while Query excuting in android Sqlite

public String[] getNewsLink(String prodcuttye) {


        Cursor  cursor = mDb.query(SQLITE_TABLE, new String[] { "productname" }, "ProdctType='"
                    + prodcuttye + "'", null, null, null, null, null);
        String[] result = new String[cursor.getCount()];

        int i = 0;
        if (cursor.moveToFirst()) {
            do {
                result[i] = cursor.getString(cursor.getColumnIndex("productname"));
                i++;
            } while (cursor.moveToNext());
        }
        if ((cursor != null) && !cursor.isClosed()) {
            cursor.close();
            mDb.close();
        }


            return result;
        }

This function for fetch data in String array i am trying to excute this Query am getting data when i am call the in Sqlite browser[ select productname from MyShopingTable where ProdctType= 'Basmati Rice'] But when i try to run this Query in function i am getting cursor count 0 so i am unable to get data please tell me where am doing wrong please suggest me

Aucun commentaire:

Enregistrer un commentaire