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

voidcopyStringToBuffer(Cursor cursor, String columnName, CharArrayBuffer buffer)
copy String To Buffer
cursor.copyStringToBuffer(cursor.getColumnIndex(columnName), buffer);
StringextractFilenameFromUri(Uri uri, Activity activity)
extract Filename From Uri
String fileName = null;
if (uri == null) {
    throw new IllegalArgumentException();
String scheme = uri.getScheme();
String path = uri.getPath();
if (path != null && scheme != null && scheme.equals("file")) {
    fileName = path.substring(path.lastIndexOf("/") + 1);
...
byte[]getBlob(Cursor cursor, String columnName)
get Blob
return cursor.getBlob(cursor.getColumnIndex(columnName));
byte[]getBlob(String columnName)
get Blob
return getBlob(cursor, columnName);
doublegetDouble(Cursor cursor, String columnName)
get Double
return cursor.getDouble(cursor.getColumnIndex(columnName));
doublegetDouble(String columnName)
get Double
return getDouble(cursor, columnName);
FilegetFileFromUri(Uri uri, Activity activity)
get File From Uri
String filePath = null;
String scheme = uri.getScheme();
filePath = uri.getPath();
if (filePath != null && scheme != null && scheme.equals("file")) {
    return new File(filePath);
String[] projection = { MediaStore.Images.ImageColumns.DATA };
Cursor c = activity.managedQuery(uri, projection, null, null, null);
...
StringgetFileNameFromUri(Uri uri, Activity activity)
get File Name From Uri
String[] projection = { MediaStore.Images.ImageColumns.DISPLAY_NAME };
String fileName = null;
Cursor c = activity.managedQuery(uri, projection, null, null, null);
if (c != null && c.moveToFirst()) {
    fileName = c.getString(0);
return fileName;
floatgetFloat(Cursor cursor, String columnName)
get Float
return cursor.getFloat(cursor.getColumnIndex(columnName));
floatgetFloat(String columnName)
get Float
return getFloat(cursor, columnName);