public void establishAccount(ServiceAcctInfo acct) { String[] args = {Integer.toString(acct.ID)}; Cursor cur = db.query("acct", AC_COLS, "service_id=?", args, null, null, null); try { if (cur.moveToNext()) return; } finally { cur.close(); } Account newAcct = new Account(); newAcct.serviceId = acct.ID; newAcct.name = acct.desc; addAccount(newAcct); }
public Account getAccountFromCursor(Cursor cur) { Account acct = new Account(); acct.ID = cur.getInt(0); acct.serviceId = cur.getInt(1); acct.name = cur.getString(2); String iAge = cur.getString(3); acct.lastUpdate = (iAge != null) ? new Date(Long.parseLong(iAge)) : null; acct.curBalAmt = cur.getDouble(4); iAge = cur.getString(5); acct.curBalDate = (iAge != null) ? new Date(Long.parseLong(iAge)) : null; acct.availBalAmt = cur.getDouble(6); iAge = cur.getString(7); acct.availBalDate = (iAge != null) ? new Date(Long.parseLong(iAge)) : null; iAge = cur.getString(8); acct.lastTrans = (iAge != null) ? new Date(Long.parseLong(iAge)) : null; return acct; }
private int addAccount(Account acct) { db.beginTransaction(); int acct_id; try { ContentValues newValue = acctValues(acct); acct_id = (int) db.insertOrThrow("acct", "name", newValue); acct.ID = acct_id; db.setTransactionSuccessful(); } finally { db.endTransaction(); } return acct_id; }