base de datos de la tienda de incendios agregar imagen para grabar
Necesito agregar imágenes jpeg a los registros db de firestore. Mi forma preferida sería en un Blob como lo he usado en los registros de Sqlite. Me he encontrado con algunos problemas al intentar esto. El siguiente es mi mejor intento hasta ahora:
public Blob getImage() {
Uri uri = Uri.fromFile(new
File(mCurrentPhotoPath));
File f1 = new File(mCurrentPhotoPath);
URL myURL = null;
try {
myURL = f1.toURI().toURL();
} catch (MalformedURLException e) {
e.printStackTrace();
}
Bitmap bitmap = null;
BitmapFactory.Options options = new
BitmapFactory.Options();
options.inPreferredConfig =
Bitmap.Config.ARGB_8888;
try {
if (myURL != null) {
, bitmap =
BitmapFactory.decodeStream(
myURL.openConnection().getInputStream());
String wBlob =
encodeToBase64(bitmap,
Bitmap.CompressFormat.JPEG, 100);
blob = fromBase64String(wBlob);
}
} catch (java.io.IOException e) {
e.printStackTrace();
}
return blob;
}
Mi problema esta en el
blob = fromBase64String (wBlob);
También tengo un problema al pasar un blob a la clase que establece el récord. intent.putExtra ("blobImage", blob); Agradezco cualquier ayuda.