-1
這是我class databasehelper extends SQLiteOpenHelper
如何從活動中獲得價值數據庫幫助者?
public List<Product>getListIndo(){
Product product = null;
List<Product>productList = new ArrayList<>();`enter code here`
openDatabase();
Cursor cursor = mDatabase.rawQuery("select * from product, null);
cursor.moveToFirst();
while (!cursor.isAfterLast()){
product = new Product(cursor.getInt(0),cursor.getString(1),cursor.getString(2),cursor.getString(3),cursor.getString(4),cursor.getString(5));
productList.add(product);
cursor.moveToNext();
}
cursor.close();
closeDatabase();
return productList;
}
將它作爲構造函數(或方法)參數傳遞。 – earthw0rmjim