Android Utililty Methods Cursor Read

List of utility methods to do Cursor Read

Description

The list of methods to do Cursor Read are organized into topic(s).

Method

intgetInt(Cursor cursor, String columnName)
get Int
return cursor.getInt(cursor.getColumnIndex(columnName));
intgetInt(String columnName)
get Int
return getInt(cursor, columnName);
longgetLong(Cursor c, String column)
get Long
return c.getLong(c.getColumnIndex(column));
longgetLong(Cursor cursor, String columnName)
get Long
return cursor.getLong(cursor.getColumnIndex(columnName));
longgetLong(String column)
get Long
return cursor.getLong(cursor.getColumnIndex(column));
longgetLong(String columnName)
get Long
return getLong(cursor, columnName);
StringgetPath(Context context, Uri uri)
get Path
final String[] projection = { MediaColumns.DATA };
final Cursor cursor = context.getContentResolver().query(uri,
        projection, null, null, null);
final int column_index = cursor
        .getColumnIndexOrThrow(MediaColumns.DATA);
cursor.moveToFirst();
return cursor.getString(column_index);
StringgetString(Cursor c, String column)
get String
return c.getString(c.getColumnIndex(column));
StringgetString(String column)
get String
return cursor.getString(cursor.getColumnIndex(column));
StringgetPhotoPathByLocalUri(Context context, Intent data)
get Photo Path By Local Uri
Uri selectedImage = data.getData();
String[] filePathColumn = { MediaStore.Images.Media.DATA };
Cursor cursor = context.getContentResolver().query(selectedImage,
        filePathColumn, null, null, null);
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
String picturePath = cursor.getString(columnIndex);
cursor.close();
...