public ActiveRecordPartialInstance last() { _limitSQL = " LIMIT 1"; String sql = makeSelectSQL(); Bundle b = new Bundle(); Cursor data = _db.rawQuery(sql, new String[] {}); this.release(); boolean last = data.moveToLast(); if (last) { Tools.putCursorToBundle(b, data); data.close(); return new ActiveRecordPartialInstance(this, b); } else { data.close(); return null; } }
public ArrayList<ActiveRecordPartialInstance> all() { String sql = makeSelectSQL(); ArrayList<ActiveRecordPartialInstance> list = new ArrayList<ActiveRecordPartialInstance>(); Cursor data = _db.rawQuery(sql, new String[] {}); this.release(); boolean next = data.moveToFirst(); while (next) { Bundle b = new Bundle(); int columnCount = data.getColumnCount(); for (int i = 0; i < columnCount; ++i) { Tools.putCursorToBundle(b, data); } list.add(new ActiveRecordPartialInstance(this, b)); next = data.moveToNext(); } data.close(); return list; }