Je développe une application et l'utilisateur a un profil, je suis capable de stocker le nom et le nom de famille, mais je ne peux pas comprendre comment stocker l'image, l'utilisateur peut le choisir dans la galerie. J'ai seulement le code pour choisir l'image et la placer dans un imageView. Des idées?Android Comment enregistrer une image de la galerie à analyser?
Voici le code:
public void loadImagefromGallery(View view) {
// Create intent to Open Image applications like Gallery, Google Photos
Intent galleryIntent = new Intent(Intent.ACTION_PICK,
MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
// Start the Intent
startActivityForResult(galleryIntent, RESULT_LOAD_IMG);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
try {
// When an Image is picked
if (requestCode == RESULT_LOAD_IMG && resultCode == RESULT_OK
&& null != data) {
// Get the Image from data
Uri selectedImage = data.getData();
String[] filePathColumn = {MediaStore.Images.Media.DATA};
// Get the cursor
Cursor cursor = getContentResolver().query(selectedImage,
filePathColumn, null, null, null);
// Move to first row
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
imgDecodableString = cursor.getString(columnIndex);
cursor.close();
ImageView imgView = (ImageView) findViewById(R.id.imageViewFotoPerfil);
// Set the Image in ImageView after decoding the String
imgView.setImageBitmap(BitmapFactory
.decodeFile(imgDecodableString));
} else {
Toast.makeText(this, "No has elegido una imagen",
Toast.LENGTH_LONG).show();
}
} catch (Exception e) {
Toast.makeText(this, "Algo salió mal", Toast.LENGTH_LONG)
.show();
}
}
Aussi je lis this tutorial mais n'est pas ce que je veux