List of usage examples for android.database Cursor getString
String getString(int columnIndex);
From source file:Main.java
/** * Return the filename from a uri./*from w w w . ja va 2 s . c o m*/ */ public static String getFilename(Context c, Uri uri) { try { String scheme = uri.getScheme(); if (scheme.equals("file")) { return uri.getLastPathSegment(); } else if (scheme.equals("content")) { String[] proj = { MediaStore.Files.FileColumns.DISPLAY_NAME }; Cursor cursor = c.getContentResolver().query(uri, proj, null, null, null); if (cursor != null && cursor.getCount() != 0) { int columnIndex = cursor.getColumnIndexOrThrow(MediaStore.Files.FileColumns.DISPLAY_NAME); cursor.moveToFirst(); return cursor.getString(columnIndex); } } } catch (Exception e) { e.printStackTrace(); } return null; }
From source file:com.example.igorklimov.popularmoviesdemo.helpers.Utility.java
public static String getBackdrop(Cursor data) { return data.getString(data.getColumnIndex(MovieContract.COLUMN_BACKDROP_PATH)); }
From source file:Main.java
/** * Get the value of the data column for this Uri. This is useful for * MediaStore Uris, and other file-based ContentProviders. * * @param context The context.//from w ww . j av a 2s .c o m * @param uri The Uri to query. * @param selection (Optional) Filter used in the query. * @param selectionArgs (Optional) Selection arguments used in the query. * @return The value of the _data column, which is typically a file path. */ public static String getDataColumn(Context context, Uri uri, String selection, String[] selectionArgs) { Cursor cursor = null; final String column = "_data"; final String[] projection = { column }; try { cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs, null); if (cursor != null && cursor.moveToFirst()) { final int column_index = cursor.getColumnIndexOrThrow(column); return cursor.getString(column_index); } } finally { if (cursor != null) cursor.close(); } return null; }
From source file:com.example.igorklimov.popularmoviesdemo.helpers.Utility.java
public static String getLength(Cursor cursor) { return cursor.getString(cursor.getColumnIndex(MovieContract.COLUMN_LENGTH)); }
From source file:com.example.igorklimov.popularmoviesdemo.helpers.Utility.java
public static String getBudget(Cursor cursor) { return cursor.getString(cursor.getColumnIndex(MovieContract.COLUMN_BUDGET)); }
From source file:com.example.igorklimov.popularmoviesdemo.helpers.Utility.java
private static String getMovieId(Cursor cursor) { return cursor.getString(cursor.getColumnIndex(MovieContract.COLUMN_MOVIE_ID)); }
From source file:com.example.igorklimov.popularmoviesdemo.helpers.Utility.java
public static String getCast(Cursor cursor) { return cursor.getString(cursor.getColumnIndex(MovieContract.COLUMN_CAST)); }
From source file:com.example.igorklimov.popularmoviesdemo.helpers.Utility.java
public static String getDirector(Cursor cursor) { return cursor.getString(cursor.getColumnIndex(MovieContract.COLUMN_DIRECTOR)); }
From source file:com.example.igorklimov.popularmoviesdemo.helpers.Utility.java
public static String getTrailerUrl(Cursor cursor) { return cursor.getString(cursor.getColumnIndex(MovieContract.COLUMN_TRAILER_URL)); }
From source file:com.example.igorklimov.popularmoviesdemo.helpers.Utility.java
public static String getAuthor(Cursor cursor) { return cursor.getString(cursor.getColumnIndex(MovieContract.COLUMN_AUTHOR)); }