I need to obtain the path where the image is saved when the user selects the image, I have this code:
// Llamada al explorador de archivos
public void elegirFoto(View vista){
Intent intent = new Intent(Intent.ACTION_GET_CONTENT, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
intent.setType("image/*");
startActivityForResult(intent.createChooser(intent, "Elige una aplicación"),COD_SELECCIONA);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode){
case COD_SELECCIONA:
myPath = data.getData();
Toast.makeText(this, String.valueOf(myPath), Toast.LENGTH_LONG).show();
break;
}
}
//Después guardo la ruta en la Base de Datos
I get a result like:
content: //com.android.providers.media.documents/document/image%643123
But I need something like this:
/storage/emulated/folder/folder/folder/image_name.jpg
Since the first way to save it in the database and show it later in image view does not find the route and the second way if, the way I show the image then is like this:
resultado = BaseDeDatos.rawQuery("select img from artics where codigo = '"+codigoR+"'", null);
path = (resultado .getString(0));
bitmap = BitmapFactory.decodeFile(path);
imgProducto.setImageBitmap(bitmap);