Saving a picture using MediaStore.Images.Media.insertImage

I have a problem saving a drawing with a file (MediaStore.Images.Media.insertImage) in a drawing application.

When I save the drawing, in the properties of the drawing, it shows two different names:

  • Title (this is the name I want)
  • Route: This is a numeric string, e.g. 1908345093845.jpg.

To be clear, here is a grab:

Why am I getting this?

The code:

else if (view.getId() == R.id.btn_guardar) {
        // save drawing
        AlertDialog.Builder saveDialog = new AlertDialog.Builder(this);
        saveDialog.setTitle("Guardar imagen");
        saveDialog.setMessage("¿Guardar imagen en la galería?");
        saveDialog.setPositiveButton("Si",
                new DialogInterface.OnClickListener() {
                    @SuppressWarnings("null")
                    public void onClick(DialogInterface dialog, int which) {
                        // save drawing
                        drawView.setDrawingCacheEnabled(true);
                        // attempt to save

                        File imgGuardada = new File(MediaStore.Images.Media
                                .insertImage(getContentResolver(), drawView
                                        .getDrawingCache(), "dibujo",
                                        "save image")); 

                        // feedback
                        if (imgGuardada !=null) {
                            Toast savedToast = Toast
                                    .makeText(
                                            getApplicationContext(),
                                            "La imagen ha sido guardada en el fondo del mar. Es broma, está en la galería.",
                                            Toast.LENGTH_SHORT);
                            savedToast.show();
                        } else {
                            Toast unsavedToast = Toast
                                    .makeText(
                                            getApplicationContext(),
                                            "La imagen no se ha guardado. Ha sido enviada a Mordor",
                                            Toast.LENGTH_SHORT);
                            unsavedToast.show();
                        }
                        drawView.destroyDrawingCache();
                    }
                });
        saveDialog.setNegativeButton("Nope",
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.cancel();
                    }
                });
        saveDialog.show();
    }

Thanks for the help guys!

Note. I have Android 4.4. Because of this?

+3
source share

All Articles