Cursor close - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Cursor close method.

This code example shows how to use the following methods:close, getColumnIndexOrThrow, getCount, getLong, moveToFirst
This code example shows how to use the following methods:close, getColumnIndexOrThrow, getLong, getString, moveToFirst
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:close, getString, moveToFirst
    } 
 
    private static String getCalendarId(Uri uri, ContentResolver cr) {
        Cursor calendar = cr.query(uri, new String[] { CALENDAR_ID_COLUMN }, null, null, null);
        try { 
            calendar.moveToFirst();
            return calendar.getString(0);
        } catch (CursorIndexOutOfBoundsException e) {
            return null; 
        } finally  { 
            calendar.close();
        } 
    } 
 
    @SuppressWarnings("nls") 
    public static boolean deleteTaskEvent(Task task) {
        boolean eventDeleted = false;
        String uri;
        if(task.containsNonNullValue(Task.CALENDAR_URI))
            uri = task.getValue(Task.CALENDAR_URI);
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:close, getInt, moveToNext
				"select exists(select _id from Events)" 
				; 
 
			c = db.rawQuery(sql, null);
 
			if(c.moveToNext()) {
				result = c.getInt(0) != 0;
			} 
		} catch (SQLException e) {
			Log.e(TAG, "Error determining if there are events to send: ", e);
		} finally { 
			if (c != null) {
				c.close();
			} 
			if (db != null) {
				db.close();
			} 
		} 
 
		return result;
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:close, getCount, getString, moveToFirst
	             	new String[]{MediaStore.Images.Media.DATA}, // Which columns to return 
	             	MediaStore.Images.Media._ID+ "=?",       // Which rows to return 
	             	new String[]{String.valueOf(id)},       // Selection arguments
	             	null);// order 
		 
		if(cursor!=null && cursor.getCount()>0)
		{ 
			cursor.moveToFirst();
			String filepath = cursor.getString(0);
			cursor.close();
			int rotation = 0;
			 
			try 
			{ 
				ExifInterface exifInterface = new ExifInterface(filepath);
				int exifRotation = exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION,ExifInterface.ORIENTATION_UNDEFINED);
 
				if(exifRotation!=ExifInterface.ORIENTATION_UNDEFINED)
				{ 
					switch(exifRotation)
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:close, getInt, getLong, getString, moveToFirst
 
        // Load the display name for the specified person 
        Cursor cursor = contentResolver.query(contactUri,
                new String[]{Contacts._ID, Contacts.DISPLAY_NAME, Contacts.PHOTO_ID}, null, null, null);
        try { 
            if (cursor.moveToFirst()) {
                contactId = cursor.getLong(0);
                contactInfo.setDisplayName(cursor.getString(1));
                contactInfo.setPhotoId(cursor.getInt(2));
            } 
        } finally { 
            cursor.close();
        } 
 
        boolean modified=false;
        cursor = contentResolver.query(Phone.CONTENT_URI,
        		new String[]{Phone.NUMBER},
                Phone.TYPE + "=" + Phone.TYPE_MOBILE+" and "+Phone.CONTACT_ID + "=" + contactId, null, null);
        try { 
        	 if (cursor.moveToNext()){
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:close, getInt, moveToFirst
		String[] colNames = new String[] {
				"MIN("+MIN_X+")", "MIN("+MIN_Y+")",
				"MAX("+MAX_X+")", "MAX("+MAX_Y+")"};
		Cursor c = database.query(GLYPHS_TABLE, colNames, COL_PAGE + "=" + page,
				null, null, null, null); 
		if (!c.moveToFirst()) return null;
		Rect r = new Rect(c.getInt(0), c.getInt(1), c.getInt(2), c.getInt(3));
		c.close();
		return r;
	} 
	 
	public void closeDatabase() { 
		if (database != null)
			database.close();
	} 
} 
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:close, getBlob, getInt, getString, moveToFirst
 
        Cursor cur = mDB.rawQuery("SELECT "
                + join(Consumers.PACKAGE_NAME, Consumers.IS_SERVICE_PUBLIC, 
                        Consumers.OWNS_CONSUMER_KEY, Consumers.REGISTRY_ID, Consumers.SIGNATURE) 
                + " FROM consumers", null); 
        assertTrue(cur.moveToFirst());
        assertEquals(PACKAGE_UNDER_TEST, cur.getString(0));
        assertEquals(0, cur.getInt(1));
        assertEquals(1, cur.getInt(2));
        assertEquals(1, cur.getInt(3));
        assertEquals(new Signature(SIGNATURE_FOR_PACKAGE), new Signature(cur.getBlob(4)));
        cur.close();
    } 
 
    public void testShouldUpdateCorrectly() throws Exception { 
        setPackage(PACKAGE_UNDER_TEST);
        setSignature(SIGNATURE_FOR_PACKAGE);
 
        ContentValues value = new ContentValues();
        value.put(Registry.ACCESS_TOKEN_URL, "http://access");
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:close, getLong, getString, moveToFirst
		Cursor cursor = contentResolver.query(contactUri,
				new String[] {
						Contacts._ID, Contacts.DISPLAY_NAME
				}, null, null, null); 
		try { 
			if (cursor.moveToFirst()) {
				contactId = cursor.getLong(0);
				contactInfo.setDisplayName(cursor.getString(1));
			} 
		} finally { 
			cursor.close();
		} 
 
		// Load the phone number (if any). 
		cursor = contentResolver.query(Phone.CONTENT_URI,
				new String[] {
					Phone.NUMBER
				}, 
				Phone.CONTACT_ID + "=" + contactId, null,
				Phone.IS_SUPER_PRIMARY + " DESC");
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:close, getLong, moveToFirst
 
    Cursor cursor = null;
 
    try { 
      cursor = db.rawQuery(sql, sqlArgs);
      if (cursor != null && cursor.moveToFirst())
        return cursor.getLong(0);
      else 
        return -1; 
    } finally { 
      if (cursor != null)
        cursor.close();
    } 
  } 
 
  public int getMessageCountForThread(long threadId) {
    SQLiteDatabase db = databaseHelper.getReadableDatabase();
    Cursor cursor     = null;
 
    try { 
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java

Related Cursor close Questions & Answers:

Other Cursor close Examples

102:				} while (cursor.moveToNext());
103:			}
104:			cursor.close();
105:			db.close();
106:	
-
149:			site.setRSSLink(cursor.getString(3));
150:			site.setDescription(cursor.getString(4));
151:			cursor.close();
152:			db.close();
153:			return site;

Read More

134:			SQLiteDatabase db = this.getReadableDatabase();
135:			Cursor cursor = db.rawQuery(countQuery, null);
136:			cursor.close();
137:	
138:			// return count

Read More

3:			SQLiteDatabase db = this.getReadableDatabase();
4:			Cursor cursor = db.rawQuery(countQuery, null);
5:			cursor.close();
6:	
7:			// return count

Read More

close Method Overview
Closes the Cursor, releasing all of its resources and making it completely invalid.
See Code Examples for other Android Cursor Methods: