所以我有一个imageArray,它找到了17个字段。但最终不会将它们填充到数组中。它说图像数组是空的。我的调试器显示日志中填充了数据库中的17个字段。但阵列未能包含它们@
imageArray.add(rn);
Java onCreate
@Override
protected void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_myreceipts);
ReceiptsOperations ro = new ReceiptsOperations(this);
List<Receipt> receipts = ro.getReceipts();
for(Receipt rn : receipts){
String log = "RECEIPTID:" + rn.getReceiptID() + "RECEIPTURI:" + rn.getReceiptURI();
Log.d("Result: ", log);
imageArray.add(rn);
}
初始化收据清单
public List<Receipt>getReceipts() {
// This code will retrieve all images from database.
List<Receipt> receiptList = new ArrayList<Receipt>();
String selectQuery = "SELECT* FROM receipts_table ORDER BY receipt_ID";
// Check all rows and add to list.
SQLiteDatabase db = this.getWritableDatabase();
Cursor cursor = db.rawQuery(selectQuery,null);
if(cursor.moveToFirst())
{
do
{
Receipt receipt = new Receipt();
receipt.setReceiptID(new String(cursor.getString(0)));
receipt.setReceiptURI(new String(cursor.getString(2)));
receiptList.add(receipt);
}
while(cursor.moveToNext());
}
db.close();
return receiptList;
}