List of usage examples for android.database Cursor getInt
int getInt(int columnIndex);
From source file:com.phonegap.ContactAccessorSdk3_4.java
/** * Create a ContactField JSONArray/*from w w w . ja va 2 s . co m*/ * @param cr database access object * @param contactId the ID to search the database for * @return a JSONArray representing a set of ContactFields */ private JSONArray phoneQuery(ContentResolver cr, String contactId) { Cursor cursor = cr.query(Phones.CONTENT_URI, null, Phones.PERSON_ID + " = ?", new String[] { contactId }, null); JSONArray phones = new JSONArray(); JSONObject phone; while (cursor.moveToNext()) { phone = new JSONObject(); try { phone.put("id", cursor.getString(cursor.getColumnIndex(Phones._ID))); phone.put("perf", false); phone.put("value", cursor.getString(cursor.getColumnIndex(Phones.NUMBER))); phone.put("type", getPhoneType(cursor.getInt(cursor.getColumnIndex(Phones.TYPE)))); phones.put(phone); } catch (JSONException e) { Log.e(LOG_TAG, e.getMessage(), e); } } return phones; }
From source file:com.hichinaschool.flashcards.libanki.importer.Anki2Importer.java
/** Cards */ private int _importCards() { // build map of (guid, ord) -> cid and used id cache mCards = new HashMap<String, HashMap<Integer, Long>>(); HashMap<Long, Boolean> existing = new HashMap<Long, Boolean>(); Cursor cursor = null; try {//from w w w. j ava 2 s . c om // "SELECT f.guid, c.ord, c.id FROM cards c, notes f WHERE c.nid = f.id" cursor = mDst.getDb().getDatabase().query("cards c, notes f", new String[] { "f.guid", "c.ord", "c.id" }, "c.nid = f.id", null, null, null, null); while (cursor.moveToNext()) { long cid = cursor.getLong(2); existing.put(cid, true); String guid = cursor.getString(0); int ord = cursor.getInt(1); if (mCards.containsKey(guid)) { mCards.get(guid).put(ord, cid); } else { HashMap<Integer, Long> map = new HashMap<Integer, Long>(); map.put(ord, cid); mCards.put(guid, map); } } } finally { if (cursor != null) { cursor.close(); } } // loop through src ArrayList<Object[]> cards = new ArrayList<Object[]>(); ArrayList<Object[]> revlog = new ArrayList<Object[]>(); int cnt = 0; int usn = mDst.usn(); long aheadBy = mSrc.getSched().getToday() - mDst.getSched().getToday(); try { cursor = mSrc.getDb().getDatabase() .rawQuery("SELECT f.guid, f.mid, c.* FROM cards c, notes f WHERE c.nid = f.id", null); int total = cursor.getCount(); int ci = 0; while (cursor.moveToNext()) { Object[] card = new Object[] { cursor.getString(0), cursor.getLong(1), cursor.getLong(2), cursor.getLong(3), cursor.getLong(4), cursor.getInt(5), cursor.getLong(6), cursor.getInt(7), cursor.getInt(8), cursor.getInt(9), cursor.getLong(10), cursor.getLong(11), cursor.getLong(12), cursor.getInt(13), cursor.getInt(14), cursor.getInt(15), cursor.getLong(16), cursor.getLong(17), cursor.getInt(18), cursor.getString(19) }; String guid = (String) card[0]; if (mChangedGuids.containsKey(guid)) { guid = mChangedGuids.get(guid); } // does the card's note exist in dst col? if (!mNotes.containsKey(guid)) { continue; } Object[] dnid = mNotes.get(guid); // does the card already exist in the dst col? int ord = (Integer) card[5]; if (mCards.containsKey(guid) && mCards.get(guid).containsKey(ord)) { // fixme: in future, could update if newer mod time continue; } // doesn't exist. strip off note info, and save src id for later Object[] oc = card; card = new Object[oc.length - 2]; for (int i = 0; i < card.length; i++) { card[i] = oc[i + 2]; } long scid = (Long) card[0]; // ensure the card id is unique while (existing.containsKey(card[0])) { card[0] = (Long) card[0] + 999; } existing.put((Long) card[0], true); // update cid, nid, etc card[1] = mNotes.get(guid)[0]; card[2] = _did((Long) card[2]); card[4] = Utils.intNow(); card[5] = usn; // review cards have a due date relative to collection if ((Integer) card[7] == 2 || (Integer) card[7] == 3 || (Integer) card[6] == 2) { card[8] = (Long) card[8] - aheadBy; } // if odid true, convert card from filtered to normal if ((Long) card[15] != 0) { // odid card[15] = 0; // odue card[8] = card[14]; card[14] = 0; // queue if ((Integer) card[6] == 1) { // type card[7] = 0; } else { card[7] = card[6]; } // type if ((Integer) card[6] == 1) { card[6] = 0; } } cards.add(card); // we need to import revlog, rewriting card ids and bumping usn Cursor cur2 = null; try { // "SELECT * FROM revlog WHERE cid = ?" cur2 = mDst.getDb().getDatabase().query("revlog", new String[] { "id", "cid", "usn", "ease", "ivl", "lastIvl", "factor", "time", "type" }, "cid = ?", new String[] { Long.toString(scid) }, null, null, null); while (cur2.moveToNext()) { Object[] rev = new Object[] { cur2.getLong(0), cur2.getLong(1), cur2.getInt(2), cur2.getInt(3), cur2.getLong(4), cur2.getLong(5), cur2.getLong(6), cur2.getLong(7), cur2.getInt(8) }; rev[1] = card[0]; rev[2] = mDst.usn(); revlog.add(rev); } } finally { if (cur2 != null) { cur2.close(); } } cnt += 1; ++ci; publishProgress(true, 100, ci * 100 / total, false); } } finally { if (cursor != null) { cursor.close(); } } // apply mDst.getDb().executeMany("INSERT OR IGNORE INTO cards VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", cards); mDst.getDb().executeMany("INSERT OR IGNORE INTO revlog VALUES (?,?,?,?,?,?,?,?,?)", revlog); return cnt; }
From source file:com.mk4droid.IMC_Services.DatabaseHandler.java
/** * Categories : Insert categories or update categories table * /*from w ww .j av a2 s . c o m*/ * @return number of downloaded bytes */ public int addUpdCateg(Context ctx) { int bdown = 0; String response = Download_Data.Download_Categories(); if (response != null) bdown += response.length(); try { JSONArray jArrCategs = new JSONArray(response); int NCateg = jArrCategs.length(); if (!db.isOpen()) db = this.getWritableDatabase(); //--------- Create Helpers for Local db ----------------- final InsertHelper iHelpC = new InsertHelper(db, TABLE_Categories); int c1 = iHelpC.getColumnIndex(KEY_CatID); int c2 = iHelpC.getColumnIndex(KEY_CatName); int c3 = iHelpC.getColumnIndex(KEY_CatIcon); int c4 = iHelpC.getColumnIndex(KEY_CatLevel); int c5 = iHelpC.getColumnIndex(KEY_CatParentID); int c6 = iHelpC.getColumnIndex(KEY_CatVisible); try { db.beginTransaction(); Log.e("UPD", "Categs"); for (int i = 0; i < NCateg; i++) { float prog = 100 * ((float) (i + 1)) / ((float) NCateg); ctx.sendBroadcast( new Intent("android.intent.action.MAIN").putExtra("progressval", (int) (prog * 0.67))); JSONArray jArrData = new JSONArray(jArrCategs.get(i).toString()); int CategID = jArrData.getInt(0); String CategName = jArrData.getString(1); int CategLevel = jArrData.getInt(2); int CategParentId = jArrData.getInt(3); String CategParams = jArrData.getString(4); JSONObject cpOb = new JSONObject(CategParams); String CategIconPath = cpOb.getString("image"); String fullPath = Constants_API.COM_Protocol + Constants_API.ServerSTR + Constants_API.remoteImages + CategIconPath; // Download icon byte[] CategIcon = Download_Data.Down_Image(fullPath); //------- Resize icon based on the device needs and store in db. -------------------- Bitmap CategIconBM = BitmapFactory.decodeByteArray(CategIcon, 0, CategIcon.length); CategIconBM = Bitmap.createScaledBitmap(CategIconBM, (int) ((float) Fragment_Map.metrics.densityDpi / 4.5), (int) ((float) Fragment_Map.metrics.densityDpi / 4), true); ByteArrayOutputStream stream = new ByteArrayOutputStream(); CategIconBM.compress(Bitmap.CompressFormat.PNG, 100, stream); CategIcon = stream.toByteArray(); //--------------------------------------------------------- bdown += CategIcon.length; // Local db Cursor cursorC = db.rawQuery("SELECT " + KEY_CatID + "," + KEY_CatVisible + " FROM " + TABLE_Categories + " WHERE " + KEY_CatID + "=" + Integer.toString(CategID), null); if (cursorC.moveToFirst()) { // Update iHelpC.prepareForReplace(); iHelpC.bind(c6, cursorC.getInt(1) == 1); } else { iHelpC.prepareForInsert(); iHelpC.bind(c6, 1); // Insert } iHelpC.bind(c1, CategID); iHelpC.bind(c2, CategName); iHelpC.bind(c3, CategIcon); iHelpC.bind(c4, CategLevel); iHelpC.bind(c5, CategParentId); cursorC.close(); iHelpC.execute(); } db.setTransactionSuccessful(); } finally { db.endTransaction(); } // TRY OF TRANSACTION } catch (JSONException e1) { e1.printStackTrace(); Log.e(Constants_API.TAG, TAG_Class + ": Categories update failed"); } // TRY OF JSONARRAY return bdown; }
From source file:com.nit.libanki.importer.Anki2Importer.java
/** Cards */ private int _importCards(boolean currDeckImport) { // build map of (guid, ord) -> cid and used id cache mCards = new HashMap<String, HashMap<Integer, Long>>(); HashMap<Long, Boolean> existing = new HashMap<Long, Boolean>(); Cursor cursor = null; try {//from ww w . java2 s. co m // "SELECT f.guid, c.ord, c.id FROM cards c, notes f WHERE c.nid = f.id" cursor = mDst.getDb().getDatabase().query("cards c, notes f", new String[] { "f.guid", "c.ord", "c.id" }, "c.nid = f.id", null, null, null, null); while (cursor.moveToNext()) { long cid = cursor.getLong(2); existing.put(cid, true); String guid = cursor.getString(0); int ord = cursor.getInt(1); if (mCards.containsKey(guid)) { mCards.get(guid).put(ord, cid); } else { HashMap<Integer, Long> map = new HashMap<Integer, Long>(); map.put(ord, cid); mCards.put(guid, map); } } } finally { if (cursor != null) { cursor.close(); } } // loop through src ArrayList<Object[]> cards = new ArrayList<Object[]>(); ArrayList<Object[]> revlog = new ArrayList<Object[]>(); int cnt = 0; int usn = mDst.usn(); long aheadBy = mSrc.getSched().getToday() - mDst.getSched().getToday(); try { cursor = mSrc.getDb().getDatabase() .rawQuery("SELECT f.guid, f.mid, c.* FROM cards c, notes f WHERE c.nid = f.id", null); int total = cursor.getCount(); int ci = 0; while (cursor.moveToNext()) { Object[] card = new Object[] { cursor.getString(0), cursor.getLong(1), cursor.getLong(2), cursor.getLong(3), cursor.getLong(4), cursor.getInt(5), cursor.getLong(6), cursor.getInt(7), cursor.getInt(8), cursor.getInt(9), cursor.getLong(10), cursor.getLong(11), cursor.getLong(12), cursor.getInt(13), cursor.getInt(14), cursor.getInt(15), cursor.getLong(16), cursor.getLong(17), cursor.getInt(18), cursor.getString(19) }; String guid = (String) card[0]; if (mChangedGuids.containsKey(guid)) { guid = mChangedGuids.get(guid); } // does the card's note exist in dst col? if (!mNotes.containsKey(guid)) { continue; } Object[] dnid = mNotes.get(guid); // does the card already exist in the dst col? int ord = (Integer) card[5]; if (mCards.containsKey(guid) && mCards.get(guid).containsKey(ord)) { // fixme: in future, could update if newer mod time continue; } // doesn't exist. strip off note info, and save src id for later Object[] oc = card; card = new Object[oc.length - 2]; for (int i = 0; i < card.length; i++) { card[i] = oc[i + 2]; } long scid = (Long) card[0]; // ensure the card id is unique while (existing.containsKey(card[0])) { card[0] = (Long) card[0] + 999; } existing.put((Long) card[0], true); // update cid, nid, etc card[1] = mNotes.get(guid)[0]; card[2] = _did((Long) card[2], currDeckImport); card[4] = Utils.intNow(); card[5] = usn; // review cards have a due date relative to collection if ((Integer) card[7] == 2 || (Integer) card[7] == 3 || (Integer) card[6] == 2) { card[8] = (Long) card[8] - aheadBy; } // if odid true, convert card from filtered to normal //if ((Long)card[15] != 0) { // odid card[15] = 0; // odue card[8] = 0; //card[14]; card[14] = 0; // queue //if ((Integer)card[6] == 1) { // type card[7] = 0; //} else { // card[7] = card[6]; //} // type //if ((Integer)card[6] == 1) { card[6] = 0; //} //} cards.add(card); // we need to import revlog, rewriting card ids and bumping usn Cursor cur2 = null; try { // "SELECT * FROM revlog WHERE cid = ?" cur2 = mDst.getDb().getDatabase().query("revlog", new String[] { "id", "cid", "usn", "ease", "ivl", "lastIvl", "factor", "time", "type" }, "cid = ?", new String[] { Long.toString(scid) }, null, null, null); while (cur2.moveToNext()) { Object[] rev = new Object[] { cur2.getLong(0), cur2.getLong(1), cur2.getInt(2), cur2.getInt(3), cur2.getLong(4), cur2.getLong(5), cur2.getLong(6), cur2.getLong(7), cur2.getInt(8) }; rev[1] = card[0]; rev[2] = mDst.usn(); revlog.add(rev); } } finally { if (cur2 != null) { cur2.close(); } } cnt += 1; ++ci; publishProgress(true, 100, ci * 100 / total, false); } } finally { if (cursor != null) { cursor.close(); } } // apply mDst.getDb().executeMany("INSERT OR IGNORE INTO cards VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", cards); mDst.getDb().executeMany("INSERT OR IGNORE INTO revlog VALUES (?,?,?,?,?,?,?,?,?)", revlog); return cnt; }
From source file:net.fluidnexus.FluidNexusAndroid.services.NexusServiceThread.java
/** * Start the listeners for zeroconf services */// w ww . j a v a2s . c om public void doStateNone() { if (wifiManager.getWifiState() == wifiManager.WIFI_STATE_ENABLED) { Cursor c = messagesProviderHelper.publicMessages(); while (c.isAfterLast() == false) { String message_hash = c.getString(c.getColumnIndex(MessagesProviderHelper.KEY_MESSAGE_HASH)); boolean result = checkHash(message_hash); if (!result) { try { JSONObject message = new JSONObject(); message.put("message_title", c.getString(c.getColumnIndex(MessagesProviderHelper.KEY_TITLE))); message.put("message_content", c.getString(c.getColumnIndex(MessagesProviderHelper.KEY_CONTENT))); message.put("message_hash", c.getString(c.getColumnIndex(MessagesProviderHelper.KEY_MESSAGE_HASH))); message.put("message_type", c.getInt(c.getColumnIndex(MessagesProviderHelper.KEY_TYPE))); message.put("message_time", c.getFloat(c.getColumnIndex(MessagesProviderHelper.KEY_TIME))); message.put("message_received_time", c.getFloat(c.getColumnIndex(MessagesProviderHelper.KEY_RECEIVED_TIME))); message.put("message_priority", c.getInt(c.getColumnIndex(MessagesProviderHelper.KEY_PRIORITY))); String attachment_path = c .getString(c.getColumnIndex(MessagesProviderHelper.KEY_ATTACHMENT_PATH)); //String serializedMessage = message.toString(); // First, get our nonce consumer = new CommonsHttpOAuthConsumer(key, secret); consumer.setTokenWithSecret(token, token_secret); HttpPost nonce_request = new HttpPost(NEXUS_NONCE_URL); consumer.sign(nonce_request); HttpClient client = new DefaultHttpClient(); String response = client.execute(nonce_request, new BasicResponseHandler()); JSONObject object = new JSONObject(response); String nonce = object.getString("nonce"); // Then, take our nonce and key and put them in the message message.put("message_nonce", nonce); message.put("message_key", key); // Setup our multipart entity MultipartEntity entity = new MultipartEntity(); // Deal with file attachment if (!attachment_path.equals("")) { File file = new File(attachment_path); ContentBody cbFile = new FileBody(file); entity.addPart("message_attachment", cbFile); // add the original filename to the message message.put("message_attachment_original_filename", c.getString( c.getColumnIndex(MessagesProviderHelper.KEY_ATTACHMENT_ORIGINAL_FILENAME))); } String serializedMessage = message.toString(); ContentBody messageBody = new StringBody(serializedMessage); entity.addPart("message", messageBody); HttpPost message_request = new HttpPost(NEXUS_MESSAGE_URL); message_request.setEntity(entity); client = new DefaultHttpClient(); client.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1); response = client.execute(message_request, new BasicResponseHandler()); object = new JSONObject(response); boolean message_result = object.getBoolean("result"); if (message_result) { ContentValues values = new ContentValues(); values.put(MessagesProviderHelper.KEY_MESSAGE_HASH, message_hash); values.put(MessagesProviderHelper.KEY_UPLOADED, 1); int res = messagesProviderHelper .setPublic(c.getLong(c.getColumnIndex(MessagesProviderHelper.KEY_ID)), values); if (res == 0) { log.debug("Message with hash " + message_hash + " not found; this should never happen!"); } } } catch (OAuthMessageSignerException e) { log.debug("OAuthMessageSignerException: " + e); } catch (OAuthExpectationFailedException e) { log.debug("OAuthExpectationFailedException: " + e); } catch (OAuthCommunicationException e) { log.debug("OAuthCommunicationException: " + e); } catch (JSONException e) { log.debug("JSON Error: " + e); } catch (IOException e) { log.debug("IOException: " + e); } } c.moveToNext(); } c.close(); } setServiceState(STATE_SERVICE_WAIT); }
From source file:com.flowzr.budget.holo.export.flowzr.FlowzrSyncEngine.java
private static JSONObject cursorToDict(String tableName, Cursor c) { int totalColumn = c.getColumnCount(); JSONObject rowObject = new JSONObject(); if (c.getColumnIndex("_id") != -1) { try {//from w w w. j a va 2 s .c o m rowObject.put("_id", c.getInt(c.getColumnIndex("_id"))); } catch (JSONException e) { e.printStackTrace(); } } for (int i = 0; i < totalColumn; i++) { if (c.getColumnName(i) != null) { String colName = c.getColumnName(i); try { if (c.getString(i) != null) { if (colName.endsWith("_id") || colName.equals("parent")) { if (tableName.equals(DatabaseHelper.BUDGET_TABLE)) { if (colName.equals("parent_budget_id")) { rowObject.put(colName, c.getInt(i)); } else if (!colName.equals("_id")) { String[] entities = c.getString(c.getColumnIndex(colName)).split(","); String keys = ""; for (String entity_id2 : entities) { keys += getRemoteKey(getTableForColName(colName), entity_id2) + ","; } if (keys.endsWith(",")) { keys = keys.substring(0, keys.length() - 1); } rowObject.put(colName, keys); } } else { if (!colName.equals("_id")) { String k = getRemoteKey(getTableForColName(colName), c.getString(i)); if (k != null) { rowObject.put(colName, k); } else { rowObject.put(colName, c.getInt(i)); } } } } else { rowObject.put(colName, c.getString(c.getColumnIndex(colName))); } /****/ if (tableName.equals(DatabaseHelper.ACCOUNT_TABLE)) { String sql = "select max(dateTime) as maxDate, min(dateTime) as minDate from " + DatabaseHelper.TRANSACTION_TABLE + " where from_account_id=" + c.getInt(c.getColumnIndex("_id")); Cursor c2 = db.rawQuery(sql, null); c2.moveToFirst(); rowObject.put("dateOfFirstTransaction", c2.getString(1)); rowObject.put("dateOfLastTransaction", c2.getString(0)); //each account can have a timezone so you can have a balance at closing day rowObject.put("tz", String.valueOf(TimeZone.getDefault().getRawOffset())); } else if (tableName.equals(DatabaseHelper.CATEGORY_TABLE)) { //load parent id Category cat = dba.getCategory(c.getInt(0)); // sql build/load parentId if (cat.getParentId() > 0) { Category pcat = em.load(Category.class, cat.getParentId()); rowObject.put("parent", pcat.remoteKey); rowObject.put("parent_id", pcat.id); } String attrPushString = ""; for (Attribute attr : dba.getAttributesForCategory(c.getInt(0))) { attrPushString = attrPushString + attr.remoteKey + ";"; } if (attrPushString != "") { rowObject.put("attributes", attrPushString); } } else if (tableName.equals(DatabaseHelper.TRANSACTION_TABLE)) { Map<Long, String> attributesMap = dba.getAllAttributesForTransaction(c.getInt(0)); String transaction_attribute = ""; for (long attributeId : attributesMap.keySet()) { transaction_attribute += dba.getAttribute(attributeId).remoteKey + "=" + attributesMap.get(attributeId) + ";"; } rowObject.put("transaction_attribute", transaction_attribute); } /****/ } else { rowObject.put(colName, ""); } } catch (JSONException e) { Log.d(TAG, e.getMessage()); } } } return rowObject; }
From source file:se.lu.nateko.edca.BackboneSvc.java
/** * Try to load a Layer from the stored information * in the local SQLite database and on the external * storage of the device.//from w w w . j a va2s. co m * @param allow Whether or not to allow the renew. Used with a flag to prevent multiple calls on application start-up. */ public void renewActiveLayer(boolean allow) { Log.d(TAG, "renewActiveLayer() called. First time: " + String.valueOf(mInitialRenewLayer)); if (allow) { mInitialRenewLayer = false; // Flag the action so it will not be executed again. /* Find the active layer if there is one and load it. */ Cursor layerCursor = getSQLhelper().fetchData(LocalSQLDBhelper.TABLE_LAYER, LocalSQLDBhelper.KEY_LAYER_COLUMNS, LocalSQLDBhelper.ALL_RECORDS, LocalSQLDBhelper.KEY_LAYER_USEMODE + " % " + LocalSQLDBhelper.LAYER_MODE_ACTIVE + " = 0", true); getActiveActivity().startManagingCursor(layerCursor); if (layerCursor.moveToFirst()) { // If there is an active layer: if (layerCursor.getInt(2) % LocalSQLDBhelper.LAYER_MODE_STORE == 0) { // If the layer is stored on the device; load it locally. Log.i(TAG, "Loading active layer from local storage..."); setActiveLayer(generateGeographyLayer(layerCursor.getString(1))); makeLoadOperation(layerCursor.getInt(0)); } else {// Else, try to load it from the geospatial server. Log.i(TAG, "Loading active layer from geospatial server..."); makeDescribeFeatureTypeRequest(getActiveServer(), layerCursor.getString(1), layerCursor.getInt(0)); } } else Log.i(TAG, "No active layer found."); } }
From source file:com.hichinaschool.flashcards.libanki.Finder.java
/** Return a list of card ids for QUERY */ public ArrayList<HashMap<String, String>> findCardsForCardBrowser(String query, String _order, HashMap<String, String> deckNames) { String[] tokens = _tokenize(query); Pair<String, String[]> res1 = _where(tokens); String preds = res1.first;/*from w ww . j av a 2 s . c om*/ String[] args = res1.second; ArrayList<HashMap<String, String>> res = new ArrayList<HashMap<String, String>>(); if (preds == null) { return res; } Pair<String, Boolean> res2 = _order(_order); String order = res2.first; boolean rev = res2.second; String sql = _query(preds, order, true); Cursor cur = null; try { cur = mCol.getDb().getDatabase().rawQuery(sql, args); while (cur.moveToNext()) { HashMap<String, String> map = new HashMap<String, String>(); map.put("id", cur.getString(0)); map.put("sfld", cur.getString(1)); map.put("deck", deckNames.get(cur.getString(2))); int queue = cur.getInt(3); String tags = cur.getString(4); map.put("flags", Integer.toString((queue == -1 ? 1 : 0) + (tags.matches(".*[Mm]arked.*") ? 2 : 0))); map.put("tags", tags); res.add(map); } } catch (SQLException e) { // invalid grouping Log.e(AnkiDroidApp.TAG, "Invalid grouping, sql: " + sql); return new ArrayList<HashMap<String, String>>(); } finally { if (cur != null) { cur.close(); } } if (rev) { Collections.reverse(res); } return res; }