List of usage examples for android.database.sqlite SQLiteDatabase query
public Cursor query(String table, String[] columns, String selection, String[] selectionArgs, String groupBy,
String having, String orderBy)
From source file:Main.java
public static Cursor searchByValue(SQLiteDatabase db, String key, String value) { return db.query(TABLE_NAME, null, FIELD_SET_NAME + "= ?," + FIELD_VALUE + "=?", new String[] { key, value }, null, null, null);/*w w w.ja v a 2 s .co m*/ }
From source file:Main.java
public static void logTableDump(SQLiteDatabase db, String tablename) { Cursor cursor = db.query(tablename, null, null, null, null, null, null); try {/*from ww w. j a v a2 s. co m*/ String dump = DatabaseUtils.dumpCursorToString(cursor); } finally { cursor.close(); } }
From source file:Main.java
public static int findPrimaryKey(SQLiteDatabase db, String address) { int key = -1; Cursor cursor = db.query(TABLE_NAME, new String[] { "DQXX01" }, "DQXX05=?", new String[] { address }, null, null, null);//from w w w . ja v a 2s . com if (cursor != null) { if (cursor.moveToNext()) { key = cursor.getInt(0); } } return key; }
From source file:Main.java
public static int findPrimaryKey(SQLiteDatabase db, String tableName, String address) { int key = -1; Cursor cursor = db.query(tableName, new String[] { "DQXX01" }, "DQXX05=?", new String[] { address }, null, null, null);//from w w w . j ava2 s.c o m if (cursor != null) { if (cursor.moveToNext()) { key = cursor.getInt(0); } } return key; }
From source file:Main.java
private static Cursor getTaskCursor(SQLiteDatabase database, String name) { String where = NAME + "='" + name + "'"; Cursor cursor = database.query(TASK_TABLE_NAME, null, where, null, null, null, null); return cursor; }
From source file:Main.java
public static long selectTopTableId(SQLiteDatabase mDB, String tableName, String tableIdColumn) { long topTaskId = 1; Cursor cursor = mDB.query(tableName, new String[] { tableIdColumn }, null, null, null, null, tableIdColumn + " DESC LIMIT 1"); assert null != cursor; try {/*from w w w . j a v a 2 s . c om*/ if (cursor.moveToFirst()) { topTaskId = cursor.getLong(0); } } finally { cursor.close(); } return topTaskId; }
From source file:Main.java
public static boolean isExist(SQLiteDatabase db, String pageId, String lang) throws SQLException { boolean itemExist = false; Cursor c = db.query(TABLE_CONTENT_HELP, null, PAGE_ID + "=? AND " + PAGE_LANGUAGE + "=?", new String[] { pageId, lang }, null, null, null); if ((c != null) && (c.getCount() > 0)) { itemExist = true;//from ww w. ja v a2 s. c om } c.close(); return itemExist; }
From source file:Main.java
public static Map<String, Integer> getProvince(SQLiteDatabase db, String tableName) { Map<String, Integer> provinceMap = new LinkedHashMap<String, Integer>(); Cursor cursor = db.query(tableName, new String[] { "DQX_DQXX01", "DQXX02" }, "DQXX03=?", new String[] { "1" }, null, null, "DQX_DQXX01 ASC"); if (cursor != null) { while (cursor.moveToNext()) { provinceMap.put(cursor.getString(1), cursor.getInt(0)); }//from www. j a v a 2 s. c o m } if (cursor != null && !cursor.isClosed()) { cursor.close(); } return provinceMap; }
From source file:Main.java
public static Map<String, Integer> getArea(SQLiteDatabase db, String tableName, int dqx_dqxx01) { Map<String, Integer> areaMap = new LinkedHashMap<String, Integer>(); Cursor cursor = db.query(tableName, new String[] { "DQXX02", "DQXX01" }, "DQX_DQXX01=?", new String[] { "" + dqx_dqxx01 }, null, null, "DQXX01 ASC"); if (cursor != null) { while (cursor.moveToNext()) { areaMap.put(cursor.getString(0), cursor.getInt(1)); }/*from w w w. ja v a 2 s . c om*/ } if (cursor != null && !cursor.isClosed()) { cursor.close(); } return areaMap; }
From source file:Main.java
public static ArrayList<ContentValues> getProvince(SQLiteDatabase db) { ArrayList<ContentValues> list = new ArrayList<ContentValues>(); ContentValues values = null;/*from w w w .ja v a 2 s .c o m*/ Cursor cursor = db.query(TABLE_NAME, new String[] { "DQXX01", "DQXX02" }, "DQXX03=?", new String[] { "1" }, null, null, "DQX_DQXX01 ASC"); if (cursor != null) { while (cursor.moveToNext()) { values = new ContentValues(); values.put("province_id", cursor.getInt(0)); values.put("province", cursor.getString(1)); list.add(values); } } if (cursor != null && !cursor.isClosed()) { cursor.close(); } return list; }