Cursor moveToFirst - 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 moveToFirst 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
Contextual code suggestions in your IDE  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
Contextual code suggestions in your IDE  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
Contextual code suggestions in your IDE  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
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:moveToFirst
	} 
 
	private void setupFeed() { 
		Uri feedUri = FeedProvider.FEEDS_URI.buildUpon().appendPath(feedId).build();
		feedCursor = contentResolver.query(feedUri, null, null, null, null);
		feedCursor.moveToFirst();
		feed = Feed.fromCursor(feedCursor);
	} 
 
	@Override 
	public Loader<Cursor> onCreateLoader(int loaderId, Bundle bundle) {
		Uri uri = FeedProvider.FEED_STORIES_URI.buildUpon().appendPath(feedId).build();
		CursorLoader cursorLoader = new CursorLoader(getActivity(), uri, null, FeedProvider.getStorySelectionFromState(currentState), null, DatabaseConstants.STORY_DATE + " DESC");
		return cursorLoader;
	} 
 
	@Override 
	public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
		if (cursor != null) {
			adapter.swapCursor(cursor);
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getCount, getLong, getString, isAfterLast, isLast
        addJulie(); 
 
        assertThat(updateName("Belvedere")).isEqualTo(2); 
 
        Cursor cursor = database.query("table_name", new String[]{"id", "name"}, null, null, null, null, null);
        assertThat(cursor.moveToFirst()).isTrue();
        assertThat(cursor.getCount()).isEqualTo(2);
 
        assertIdAndName(cursor, 1234L, "Belvedere");
        assertThat(cursor.moveToNext()).isTrue();
 
        assertIdAndName(cursor, 1235L, "Belvedere");
        assertThat(cursor.isLast()).isTrue();
        assertThat(cursor.moveToNext()).isFalse();
        assertThat(cursor.isAfterLast()).isTrue();
        assertThat(cursor.moveToNext()).isFalse();
    } 
 
    @Test 
    public void testDelete() throws Exception { 

8
CodeRank
Contextual code suggestions in your IDE  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
Contextual code suggestions in your IDE  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
Contextual code suggestions in your IDE  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
Contextual code suggestions in your IDE  Get Codota for Java

Related Cursor moveToFirst Questions & Answers:

Other Cursor moveToFirst Examples

90:	
91:			// looping through all rows and adding to list
92:			if (cursor.moveToFirst()) {
93:				do {
94:					WebSite site = new WebSite();
-
139:					new String[] { String.valueOf(id) }, null, null, null, null);
140:			if (cursor != null)
141:				cursor.moveToFirst();
142:	
143:			WebSite site = new WebSite(cursor.getString(1), cursor.getString(2),

Read More

74:					new String[] { String.valueOf(id) }, null, null, null, null);
75:			if (cursor != null)
76:				cursor.moveToFirst();
77:	
78:			Contact contact = new Contact(Integer.parseInt(cursor.getString(0)),
-
92:	
93:			// looping through all rows and adding to list
94:			if (cursor.moveToFirst()) {
95:				do {
96:					Contact contact = new Contact();

Read More

8:	
9:			// looping through all rows and adding to list
10:			if (cursor.moveToFirst()) {
11:				do {
12:					Contact contact = new Contact();

Read More

moveToFirst Method Overview
Move the cursor to the first row.
See Code Examples for other Android Cursor Methods: