get Content Name : ContentResolver « Core Class « Android






get Content Name

    
import android.content.ContentResolver;
import android.database.Cursor;
import android.net.Uri;
import android.provider.MediaStore;

class Main {
  public static String getContentName(ContentResolver resolver, Uri uri) {
    Cursor cursor = resolver.query(uri, null, null, null, null);
    cursor.moveToFirst();
    int nameIndex = cursor
        .getColumnIndex(MediaStore.MediaColumns.DISPLAY_NAME);
    if (nameIndex >= 0) {
      return cursor.getString(nameIndex);
    } else {
      return null;
    }
  }
}

   
    
    
    
  








Related examples in the same category

1.Using ContentResolver
2.Get Path from Uri and ContentResolver