public Object execute() throws Exception {
JSONArray result = new JSONArray();
DBHelper dbh = new DBHelper(mContext);
SQLiteDatabase db = dbh.getReadableDatabase();
try{
Cursor cursor_products = db.rawQuery(dbh.GET_ALL_PRODUCTS,null);
//Cursor cursor_products = db.query(DBHelper.PRODUCT_TABLE, new String[]{DBHelper.PRODUCT_ID,DBHelper.PRODUCT_NAME,DBHelper.PRODUCT_PRICE,DBHelper.PRODUCT_QTY}, null, null, null, null, DBHelper.PRODUCT_NAME + " ASC" );
while(cursor_products.moveToNext()){
JSONObject product = new JSONObject();
product.put("id", cursor_products.getInt(0));
product.put("name", cursor_products.getString(1));
product.put("price", cursor_products.getInt(2));
product.put("stock", cursor_products.getInt(3));
result.put(product);
}
cursor_products.close();
}catch(SQLException e){
Log.e(this.getClass().getName()+"@54", e.getMessage());
}finally{
db.close();
dbh.close();
}
return result;
}
Using the above code, the error occurs at the line: Cursor cursor_products = db.rawQuery(dbh.GET_ALL_PRODUCTS,null);
which is really weird because im sure my assignments are correct.
Is there a chance that its only Eclipse not parsing the code correctly?