Tengo este método:
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);
}
Desafortunadamente, el compilador me mostró un problema en:
Cursor cursor = managedQuery(contentUri, proj, null, null, null);
Porque managedQuery()está en desuso.
¿Cómo podría reescribir este método sin usarlo managedQuery()?
java
android
deprecated
AndreaF
fuente
fuente

file://Los URI generalmente no se pueden resolver usandocontentUri: si tiene un URI de archivo, YA tiene la ruta real.new File(new URI(uri.getPath()));.new File(new URI(uri.getPath())).getAbsolutePath();es lo que necesitas, ¿no?fuente
necesita inicializar el cursor porque estará cerca antes del inicio del método o en algún otro lugar
fuente