2016-08-25 43 views
-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; 
    } 
+0

将它作为构造函数(或方法)参数传递。 – earthw0rmjim

回答

0

哪个值你想传递给databasehelper?您在您的sql查询中使用select方法,这意味着从表product中检索不插入的数据。如果将某些东西插入数据库中,则必须使用INSERT INTO table_name