Deprecated ManagedQuery() issue

You could replace it with context.getContentResolver().query and LoaderManager (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?

public String getRealPathFromURI(Uri contentUri) {
    String res = null;
    String[] proj = { MediaStore.Images.Media.DATA };
    Cursor cursor = getContentResolver().query(contentUri, proj, null, null, null);
    if(cursor.moveToFirst()){;
       int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
       res = cursor.getString(column_index);
    }
    cursor.close();
    return res;
}

Leave a Comment