- public synchronized void loadData(SQLiteDatabase db) {
- if (dataLoaded)
- return;
-
- try (Cursor cTr = db.rawQuery(
- "SELECT year, month, day, description, comment from transactions WHERE id=?",
- new String[]{String.valueOf(id)}))
- {
- if (cTr.moveToFirst()) {
- date = new SimpleDate(cTr.getInt(0), cTr.getInt(1), cTr.getInt(2));
- description = cTr.getString(3);
- comment = cTr.getString(4);
-
- accounts.clear();
-
- try (Cursor cAcc = db.rawQuery(
- "SELECT account_name, amount, currency, comment FROM " +
- "transaction_accounts WHERE transaction_id = ?",
- new String[]{String.valueOf(id)}))
- {
- while (cAcc.moveToNext()) {
-// debug("transactions",
-// String.format("Loaded %d: %s %1.2f %s", id, cAcc.getString(0),
-// cAcc.getFloat(1), cAcc.getString(2)));
- addAccount(new LedgerTransactionAccount(cAcc.getString(0), cAcc.getFloat(1),
- cAcc.getString(2), cAcc.getString(3)));
- }
-
- finishLoading();
- }
- }
- }
-
- }