Inside the emulator, the path of an image appears to me:
/storage/emulated/0/Pictures/Screenshots/454980.png
But with the following code:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK){
path = data.getData();
imagen.setImageURI(path);
}
}
You get this route from the same image:
content: // media / external / images / media / 78
When trying to load the image with the previous path, the image is not visible and shows this error:
E / BitmapFactory: Unable to decode stream: java.io.FileNotFoundException: / content: / media / external / images / media / 78: open failed: ENOENT (Not such file or directory)
I want to know why the method gives me a route which does not take me to the image I select.
With this code I try to load the image, I emphasize that the route obtained with the previous method I save it in database sqlite.
private void buscar() {
SQLiteDatabase db = mDbHelper.getReadableDatabase();
Cursor cursor = db.rawQuery("SELECT foto FROM " + Utilidades.Tabla_Contacto + " WHERE " + Utilidades.Campo_telef + " = '"+numero + "'",null);
cursor.moveToFirst();
Toast.makeText(this,cursor.getString(0),Toast.LENGTH_LONG).show();
try{
imagen.setImageURI(Uri.parse(cursor.getString(0)));
}catch(Exception e){
Toast.makeText(this,e+"",Toast.LENGTH_LONG).show();
}
db.close();
}