Cursor moveToNext - 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 moveToNext method.

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
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
This code example shows how to use the following methods:close, getString, moveToNext
 
    public static String getString(Context context, String name, String defaultValue) {
        SQLiteDatabase db = new SuperuserDatabaseHelper(context).getReadableDatabase();
        Cursor cursor = db.query("settings", new String[] { "value" }, "key='" + name + "'", null, null, null, null);
        try { 
            if (cursor.moveToNext())
                return cursor.getString(0);
        } 
        finally { 
            cursor.close();
            db.close();
        } 
        return defaultValue;
    } 
 
    public static void setInt(Context context, String name, int value) {
        setString(context, name, ((Integer) value).toString());
    } 
 
    public static int getInt(Context context, String name, int defaultValue) {
7
CodeRank
This code example shows how to use the following methods:close, getLong, moveToNext
    SQLiteDatabase db = this.dbHelper.getReadableDatabase();
    try { 
      Cursor cursor = db.query(TABLE, MAX_CREATED_AT_COLUMNS, null, null, null,
          null, null); 
      try { 
        return cursor.moveToNext() ? cursor.getLong(0) : Long.MIN_VALUE;
      } finally { 
        cursor.close();
      } 
    } finally { 
      db.close();
    } 
  } 
 
  /** 
   *  
   * @param id of the status we are looking for 
   * @return Text of the status 
   */ 
  public String getStatusTextById(long id) {  // <11>
7
CodeRank
This code example shows how to use the following methods:close, getLong, getString, moveToNext
        // Read the database directly.  We only do this once to initialize 
        // the members of this class. 
        Cursor cursor = db.query("CalendarMetaData", sCalendarMetaDataProjection,
                null, null, null, null, null); 
        try { 
            if (cursor.moveToNext()) {
                timezone = cursor.getString(METADATA_INDEX_LOCAL_TIMEZONE);
                minInstance = cursor.getLong(METADATA_INDEX_MIN_INSTANCE);
                maxInstance = cursor.getLong(METADATA_INDEX_MAX_INSTANCE);
            } 
        } finally { 
            if (cursor != null) {
                cursor.close();
            } 
        } 
 
        // Cache the result of reading the database 
        mFields.timezone = timezone;
        mFields.minInstance = minInstance;
        mFields.maxInstance = maxInstance;
7
CodeRank
This code example shows how to use the following methods:moveToNext
        try { 
            SQLiteDatabase db = getReadableDatabase();
            cursor = db.query(TABLE_WIDGETS, PROJECTION,
                    WHERE_CLAUSE, new String[] {String.valueOf(appWidgetId)},
                    null, null, null); 
            if (cursor == null || !cursor.moveToNext()) {
                Log.e(TAG, "query fail: empty cursor: " + cursor);
                return null; 
            } 
            return new Entry(appWidgetId, cursor);
        } catch (Throwable e) {
            Log.e(TAG, "Could not load photo from database", e);
            return null; 
        } finally { 
            Utils.closeSilently(cursor);
        } 
    } 
 
    /** 
     * Remove any bitmap associated with the given appWidgetId. 
7
CodeRank
This code example shows how to use the following methods:close, getString, moveToNext
		Cursor cur = null;
		 
		try { 
			cur = db.rawQuery(q.getExecutableSql(), null);
			 
			if (!cur.moveToNext()){
				return null; 
			} else { 
				return cur.getString(0);
			} 
		} catch (SQLiteException e) {
			throwError(e);
			return null; 
		} finally { 
			if (cur != null)
				cur.close();
		} 
	} 
 
	@Override 
	public Object getLastInsertId() {
7
CodeRank
This code example shows how to use the following methods:close, getLong, moveToNext
    SQLiteDatabase db = this.dbHelper.getReadableDatabase();
    try { 
      Cursor cursor = db.query(TABLE, MAX_CREATED_AT_COLUMNS, null, null, null,
          null, null); 
      try { 
        return cursor.moveToNext() ? cursor.getLong(0) : Long.MIN_VALUE;
      } finally { 
        cursor.close();
      } 
    } finally { 
      db.close();
    } 
  } 
 
  public String getStatusTextById(long id) {
    SQLiteDatabase db = this.dbHelper.getReadableDatabase();
    try { 
      Cursor cursor = db.query(TABLE, DB_TEXT_COLUMNS, C_ID + "=" + id, null,
          null, null, null); 
      try { 
7
CodeRank
This code example shows how to use the following methods:moveToNext
    return wrappedCursor.moveToLast();
  } 
 
  @Implementation 
  public boolean moveToNext() { 
    return wrappedCursor.moveToNext();
  } 
 
  @Implementation 
  public boolean moveToPrevious() { 
    return wrappedCursor.moveToPrevious();
  } 
 
  @Implementation 
  public boolean isFirst() { 
    return wrappedCursor.isFirst();
  } 
 
  @Implementation 
  public boolean isLast() { 
7
CodeRank
This code example shows how to use the following methods:close, getDouble, getLong, moveToNext
 
        ContentResolver contentResolver = context.getContentResolver();
        Cursor cursor = null;
        try { 
            cursor = contentResolver.query(sourceUri, IMAGE_PROJECTION, null, null, null);
            if ((cursor != null) && cursor.moveToNext()) {
                dateTaken = cursor.getLong(INDEX_DATE_TAKEN);
                latitude = cursor.getDouble(INDEX_LATITUDE);
                longitude = cursor.getDouble(INDEX_LONGITUDE);
            } 
        } catch (Exception e) {
            // Ignore error for lacking property columns from the source. 
        } finally { 
            if (cursor != null) {
                cursor.close();
            } 
        } 
 
        ContentValues values = new ContentValues();
        values.put(Images.Media.TITLE, saveFileName);
7
CodeRank

Related Cursor moveToNext Questions & Answers:

Other Cursor moveToNext Examples

100:					// Adding contact to list
101:					siteList.add(site);
102:				} while (cursor.moveToNext());
103:			}
104:			cursor.close();

Read More

100:					// Adding contact to list
101:					contactList.add(contact);
102:				} while (cursor.moveToNext());
103:			}
104:

Read More

16:					// Adding contact to list
17:					contactList.add(contact);
18:				} while (cursor.moveToNext());
19:			}
20:

Read More

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