我的android应用正在将数据保存到Sqlite。我正在设置一个游标来检索它,我的问题是在安装该应用程序后,游标仅一次返回数据。尽管SQLiteDB中有数据,但后续查询不会返回数据。请帮助
我尝试在任何使用过的地方关闭光标
public ArrayListretrieveDPdataFromLocalDB(){
ArrayList<DPServerResponseBean> arrayDPofflineData = new ArrayList<>();
Cursor c = getReadableDatabase().rawQuery("select * from " + Utils.DIAPER_TABLE,null);
DPServerResponseBean dpServerResponseBean;
if (c != null){
Log.v("Mealdata", " C is not null");
if (c.moveToFirst()){
Log.v("Mealdata", " movetofirst is true");
do {
dpServerResponseBean = new DPServerResponseBean();
dpServerResponseBean.d_db_id =c.getString(c.getColumnIndex( Utils._ID));
dpServerResponseBean.child_id=c.getString(c.getColumnIndex( Utils.CHILD_ID));
dpServerResponseBean.potty_detail_id=c.getString(c.getColumnIndex( Utils.P_DETAIL_ID));
dpServerResponseBean.potty_time=c.getString(c.getColumnIndex( Utils.CHECKED_AT));
dpServerResponseBean.potty_type=c.getString(c.getColumnIndex( Utils.P_TYPE));
dpServerResponseBean.potty_state=c.getString(c.getColumnIndex( Utils.P_STATE));
dpServerResponseBean.potty_details=c.getString(c.getColumnIndex( Utils.P_DETAILS));
dpServerResponseBean.checked_by=c.getString(c.getColumnIndex( Utils.TEACHER));
dpServerResponseBean.notes=c.getString(c.getColumnIndex( Utils.NOTES));
arrayDPOfflineData.add(dpServerResponseBean);
} while (c.moveToNext());
c.close();
}
}
return arrayDPOfflineData;
}
我想要方法来检索数据