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

This code example shows how to use the following methods:getString, moveToPosition
    setListAdapter(new BookmarkAdapter(this, cursor));
  } 
 
  @Override 
  protected void onListItemClick(ListView l, View view, int position, long id) {
    if (cursor.moveToPosition(position)) {
      Intent intent = new Intent();
      intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
      intent.putExtra(Browser.BookmarkColumns.TITLE, cursor.getString(TITLE_COLUMN));
      intent.putExtra(Browser.BookmarkColumns.URL, cursor.getString(URL_COLUMN));
      setResult(RESULT_OK, intent);
    } else { 
      setResult(RESULT_CANCELED);
    } 
    finish();
  } 
} 
9
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getInt, getString
        mContactAccessor = ContactAccessor.getInstance();
    } 
 
    @Override 
    public final CharSequence convertToString(Cursor cursor) {
        String name = cursor.getString(RecipientsAdapter.NAME_INDEX);
        int type = cursor.getInt(RecipientsAdapter.TYPE_INDEX);
        String number = cursor.getString(RecipientsAdapter.NUMBER_INDEX).trim();
 
        String label = cursor.getString(RecipientsAdapter.LABEL_INDEX);
        CharSequence displayLabel = mContactAccessor.phoneTypeToString(mContext, type, label);
 
        if (number.length() == 0) {
            return number;
        } 
 
        if (name == null) {
            name = "";
        } else { 
            // Names with commas are the bane of the recipient editor's existence. 

9
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:close, getColumnIndexOrThrow, getLong, getString, moveToFirst
8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getColumnIndexOrThrow, getString, isAfterLast, moveToPosition
                args, R.string.user_dict_settings_add_dialog_title, null, null, 0);
    } 
 
    private String getWord(final int position) {
        if (null == mCursor) return null;
        mCursor.moveToPosition(position);
        // Handle a possible race-condition 
        if (mCursor.isAfterLast()) return null;
 
        return mCursor.getString(
                mCursor.getColumnIndexOrThrow(UserDictionary.Words.WORD));
    } 
 
    private String getShortcut(final int position) {
        if (null == mCursor) return null;
        mCursor.moveToPosition(position);
        // Handle a possible race-condition 
        if (mCursor.isAfterLast()) return null;
 
        return mCursor.getString(

8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getInt, getLong, getString, isNull
 
    /** @inheritdoc */ 
    @Override 
    public SpecialNamesEntity readEntity(Cursor cursor, int offset) {
        SpecialNamesEntity entity = new SpecialNamesEntity( //
            cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // count
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // select
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // sum
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // avg
            cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // join
            cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // distinct
            cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // on
            cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // index
            cursor.isNull(offset + 9) ? null : cursor.getInt(offset + 9) // order
        ); 
        return entity;
    } 
      
    /** @inheritdoc */ 
8
CodeRank
Experience pair programming with AI  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
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getColumnIndex, getInt, getLong, getString, isNull
        final boolean validIcon = mResPackage != null && mIconRes != -1;
        return validIcon ? pm.getDrawable(mResPackage, mIconRes, null) : null;
    } 
 
    private static String getString(Cursor cursor, String columnName) {
        return cursor.getString(cursor.getColumnIndex(columnName));
    } 
 
    private static int getInt(Cursor cursor, String columnName) {
        return cursor.getInt(cursor.getColumnIndex(columnName));
    } 
 
    private static int getInt(Cursor cursor, String columnName, int missingValue) {
        final int columnIndex = cursor.getColumnIndex(columnName);
        return cursor.isNull(columnIndex) ? missingValue : cursor.getInt(columnIndex);
    } 
 
    private static long getLong(Cursor cursor, String columnName, long missingValue) {
        final int columnIndex = cursor.getColumnIndex(columnName);
        return cursor.isNull(columnIndex) ? missingValue : cursor.getLong(columnIndex);

8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getLong, getString
        loadFromCursor(c);
        mDiffDataValues = new ContentValues();
    } 
 
    private void loadFromCursor(Cursor c) {
        mDataId = c.getLong(DATA_ID_COLUMN);
        mDataMimeType = c.getString(DATA_MIME_TYPE_COLUMN);
        mDataContent = c.getString(DATA_CONTENT_COLUMN);
        mDataContentData1 = c.getLong(DATA_CONTENT_DATA_1_COLUMN);
        mDataContentData3 = c.getString(DATA_CONTENT_DATA_3_COLUMN);
    } 
 
    public void setContent(JSONObject js) throws JSONException {
        long dataId = js.has(DataColumns.ID) ? js.getLong(DataColumns.ID) : INVALID_ID;
        if (mIsCreate || mDataId != dataId) {
            mDiffDataValues.put(DataColumns.ID, dataId);
        } 
        mDataId = dataId;
 
        String dataMimeType = js.has(DataColumns.MIME_TYPE) ? js.getString(DataColumns.MIME_TYPE)
8
CodeRank
Experience pair programming with AI  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
Experience pair programming with AI  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
Experience pair programming with AI  Get Codota for Java

Related Cursor getString Questions & Answers:

Other Cursor getString Examples

93:				do {
94:					WebSite site = new WebSite();
95:					site.setId(Integer.parseInt(cursor.getString(0)));
96:					site.setTitle(cursor.getString(1));
97:					site.setLink(cursor.getString(2));
-
94:					WebSite site = new WebSite();
95:					site.setId(Integer.parseInt(cursor.getString(0)));
96:					site.setTitle(cursor.getString(1));
97:					site.setLink(cursor.getString(2));
98:					site.setRSSLink(cursor.getString(3));
-
95:					site.setId(Integer.parseInt(cursor.getString(0)));
96:					site.setTitle(cursor.getString(1));
97:					site.setLink(cursor.getString(2));
98:					site.setRSSLink(cursor.getString(3));
99:					site.setDescription(cursor.getString(4));
-
96:					site.setTitle(cursor.getString(1));
97:					site.setLink(cursor.getString(2));
98:					site.setRSSLink(cursor.getString(3));
99:					site.setDescription(cursor.getString(4));
100:					// Adding contact to list
-
97:					site.setLink(cursor.getString(2));
98:					site.setRSSLink(cursor.getString(3));
99:					site.setDescription(cursor.getString(4));
100:					// Adding contact to list
101:					siteList.add(site);
-
141:				cursor.moveToFirst();
142:	
143:			WebSite site = new WebSite(cursor.getString(1), cursor.getString(2),
144:					cursor.getString(3), cursor.getString(4));
145:	
-
141:				cursor.moveToFirst();
142:	
143:			WebSite site = new WebSite(cursor.getString(1), cursor.getString(2),
144:					cursor.getString(3), cursor.getString(4));
145:	
-
142:	
143:			WebSite site = new WebSite(cursor.getString(1), cursor.getString(2),
144:					cursor.getString(3), cursor.getString(4));
145:	
146:			site.setId(Integer.parseInt(cursor.getString(0)));
-
142:	
143:			WebSite site = new WebSite(cursor.getString(1), cursor.getString(2),
144:					cursor.getString(3), cursor.getString(4));
145:	
146:			site.setId(Integer.parseInt(cursor.getString(0)));
-
144:					cursor.getString(3), cursor.getString(4));
145:	
146:			site.setId(Integer.parseInt(cursor.getString(0)));
147:			site.setTitle(cursor.getString(1));
148:			site.setLink(cursor.getString(2));
-
145:	
146:			site.setId(Integer.parseInt(cursor.getString(0)));
147:			site.setTitle(cursor.getString(1));
148:			site.setLink(cursor.getString(2));
149:			site.setRSSLink(cursor.getString(3));
-
146:			site.setId(Integer.parseInt(cursor.getString(0)));
147:			site.setTitle(cursor.getString(1));
148:			site.setLink(cursor.getString(2));
149:			site.setRSSLink(cursor.getString(3));
150:			site.setDescription(cursor.getString(4));
-
147:			site.setTitle(cursor.getString(1));
148:			site.setLink(cursor.getString(2));
149:			site.setRSSLink(cursor.getString(3));
150:			site.setDescription(cursor.getString(4));
151:			cursor.close();
-
148:			site.setLink(cursor.getString(2));
149:			site.setRSSLink(cursor.getString(3));
150:			site.setDescription(cursor.getString(4));
151:			cursor.close();
152:			db.close();

Read More

76:				cursor.moveToFirst();
77:	
78:			Contact contact = new Contact(Integer.parseInt(cursor.getString(0)),
79:					cursor.getString(1), cursor.getString(2));
80:			// return contact
-
77:	
78:			Contact contact = new Contact(Integer.parseInt(cursor.getString(0)),
79:					cursor.getString(1), cursor.getString(2));
80:			// return contact
81:			return contact;
-
77:	
78:			Contact contact = new Contact(Integer.parseInt(cursor.getString(0)),
79:					cursor.getString(1), cursor.getString(2));
80:			// return contact
81:			return contact;
-
95:				do {
96:					Contact contact = new Contact();
97:					contact.setID(Integer.parseInt(cursor.getString(0)));
98:					contact.setName(cursor.getString(1));
99:					contact.setPhoneNumber(cursor.getString(2));
-
96:					Contact contact = new Contact();
97:					contact.setID(Integer.parseInt(cursor.getString(0)));
98:					contact.setName(cursor.getString(1));
99:					contact.setPhoneNumber(cursor.getString(2));
100:					// Adding contact to list
-
97:					contact.setID(Integer.parseInt(cursor.getString(0)));
98:					contact.setName(cursor.getString(1));
99:					contact.setPhoneNumber(cursor.getString(2));
100:					// Adding contact to list
101:					contactList.add(contact);

Read More

11:				do {
12:					Contact contact = new Contact();
13:					contact.setID(Integer.parseInt(cursor.getString(0)));
14:					contact.setName(cursor.getString(1));
15:					contact.setPhoneNumber(cursor.getString(2));
-
12:					Contact contact = new Contact();
13:					contact.setID(Integer.parseInt(cursor.getString(0)));
14:					contact.setName(cursor.getString(1));
15:					contact.setPhoneNumber(cursor.getString(2));
16:					// Adding contact to list
-
13:					contact.setID(Integer.parseInt(cursor.getString(0)));
14:					contact.setName(cursor.getString(1));
15:					contact.setPhoneNumber(cursor.getString(2));
16:					// Adding contact to list
17:					contactList.add(contact);

Read More

getString Method Overview
Returns the value of the requested column as a String.
See Code Examples for other Android Cursor Methods: