I'll try to explain my problem. I've created a little project based on Zxing library for reading and storing barcodes. Now I've to create my first ListView, containing the elements from the working SQLite db. Here is an extract of my source code
DBAdapter
public boolean insertProduct(String barcode, int quantity)
{
ContentValues initialValues = new ContentValues();
initialValues.put(KEY_BARCODE, barcode);
initialValues.put(KEY_QUANTITY, quantity);
try {
db.insert(DATABASE_TABLE, null, initialValues);
return true;
}
catch(Exception ex){
return false;
}
}
public boolean deleteProduct(String barcode)
{
return db.delete(DATABASE_TABLE, KEY_BARCODE + "=" + barcode, null) > 0;
}
public Cursor getAllProducts()
{
return db.query(DATABASE_TABLE, new String[] {KEY_ROWID, KEY_BARCODE, KEY_QUANTITY}, null, null, null, null, null);
}
Now I don't know how to populate the ListView in Activity class. Could someone help me?