0
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?

4

1 に答える 1

0

//これを試して

Cursor cursor_products = db.rawQuery(GET_ALL_PRODUCTS,null);

于 2012-11-28T11:42:15.027 に答える