我基于此链接创建了动态微调器:
https://www.androidtutorialpoint.com/basics/dynamically-add-and-remove-views-in-android
微调器从sqlite表中检索数据,这是我在dbhelper上的功能:
List<Customer> customers = new ArrayList<Customer>();
Customer c = new Customer();
c.setProperties....
customers.add( c );
这是我的活动代码:
//getting all location from database
public List<String> getAllFlock()
{
List<String> flockList=new ArrayList<>();
//get readable database
SQLiteDatabase db=this.getReadableDatabase();
Cursor cursor=db.rawQuery("SELECT name FROM flock",null);
if(cursor.moveToFirst())
{
do {
flockList.add(cursor.getString(0));
}while (cursor.moveToNext());
}
//close the cursor
cursor.close();
//close the database
db.close();
return flockList;
}
第一个微调器成功获取数据,但是第二个和之后未能从表获取数据。
我该如何解决?