I have this method:
public String getRealPathFromURI(Uri contentUri) {
String[] proj = { MediaStore.Images.Media.DATA };
Cursor cursor = managedQuery(contentUri, proj, null, null, null);
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
return cursor.getString(column_index);
}
Unfortunately the compiler show me a problem on:
Cursor cursor = managedQuery(contentUri, proj, null, null, null);
Because managedQuery() is deprecated.
How could I rewrite this method without use managedQuery()?
You could replace it with
context.getContentResolver().queryandLoaderManager(you’ll need to use the compatibility package to support devices before API version 11).However, it looks like you’re only using the query one time: you probably don’t even need that. Maybe this would work?