List of usage examples for android.database Cursor close
void close();
From source file:Main.java
public static void closeSafely(Cursor cursor) { try {// w w w. j a v a 2s. c o m if (cursor != null && !cursor.isClosed()) { cursor.close(); } } catch (Exception e) { e.printStackTrace(); } }
From source file:Main.java
public static void closeSilently(Cursor cursor) { try {//from w w w. jav a 2s . com if (cursor != null) cursor.close(); } catch (Throwable t) { Log.w(TAG, "fail to close", t); } }
From source file:Main.java
public static void closeQuietly(Cursor cursor) { if (cursor != null) { try {//from w ww . ja v a 2s .c o m cursor.close(); } catch (Throwable ignored) { } } }
From source file:Main.java
public static int getGroupCount(SQLiteDatabase db) { int count = 0; Cursor cursor = db.rawQuery("select count(*) from classlist", null); cursor.moveToNext();//www. j ava 2 s . co m count = cursor.getInt(0); cursor.close(); return count; }
From source file:Main.java
public static int queryCount(SQLiteDatabase db, String tableName, String where, String[] whereArgs) { StringBuffer stringBuffer = new StringBuffer("select count(*) from "); stringBuffer.append(tableName);/*from w w w . jav a 2 s . c o m*/ if (where != null) { stringBuffer.append(" where "); stringBuffer.append(where); } Cursor cursor = db.rawQuery(stringBuffer.toString(), whereArgs); cursor.moveToFirst(); int count = cursor.getInt(0); cursor.close(); return count; }
From source file:Main.java
public static int getGroupCount(SQLiteDatabase db) { int result = 0; // SQLiteDatabase db = SQLiteDatabase.openDatabase(path, null, SQLiteDatabase.OPEN_READONLY); Cursor cursor = db.rawQuery("select count(*) from classlist;", null); cursor.moveToFirst();// w w w. j a v a2 s .com result = cursor.getInt(0); cursor.close(); // db.close(); return result; }
From source file:Main.java
private static ArrayList<String> readStrings(SQLiteDatabase db, String query, int colIdx) { ArrayList<String> rows = new ArrayList<String>(); Cursor c = db.rawQuery(query, null); while (c.moveToNext()) { rows.add(c.getString(colIdx));/*from w w w. j ava 2 s . c o m*/ } c.close(); return rows; }
From source file:Main.java
public static void closeSilently(Cursor cursor) { if (cursor == null) return;//from ww w. j av a 2s . co m try { if (cursor != null) cursor.close(); } catch (Throwable t) { } }
From source file:Main.java
public static boolean hasDraftsToMigrate(Context context) { try {// ww w .j av a 2 s . co m SQLiteDatabase db = context.openOrCreateDatabase(DEPRECATED_DATABASE_NAME, 0, null); String byString = "localDraft=1 OR isLocalChange=1"; Cursor c = db.query(DEPRECATED_POSTS_TABLE, null, byString, null, null, null, null); if (c.getCount() > 0) { c.close(); return true; } c.close(); return false; } catch (SQLException e) { return false; } }
From source file:Main.java
public static void removeFromPlaylist(ContentResolver resolver, int audioId, long playlistId) { String[] cols = new String[] { "count(*)" }; Uri uri = MediaStore.Audio.Playlists.Members.getContentUri("external", playlistId); Cursor cur = resolver.query(uri, cols, null, null, null); cur.moveToFirst();/*from ww w.j ava 2 s.co m*/ final int base = cur.getInt(0); cur.close(); ContentValues values = new ContentValues(); resolver.delete(uri, MediaStore.Audio.Playlists.Members.AUDIO_ID + "=" + audioId, null); }