Tengo un botón, y quiero cuando hago clic en él, la imagen se guarda en la tarjeta sd (o en el almacenamiento interno, como en htc one x no tenemos un almacenamiento externo como una tarjeta SD)Android guardar Bitmap a tarjeta SD
este es mi código:
sd.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
MpClick.start();
File myDir=new File("/sdcard/Saved_images");
myDir.mkdirs();
Random generator = new Random();
int n = 10000;
n = generator.nextInt(n);
String fname = "Image-"+ n +".jpg";
File file = new File (myDir, fname);
if (file.exists()) file.delete();
try {
FileOutputStream out = new FileOutputStream(file);
bitMapToShare.compress(Bitmap.CompressFormat.JPEG, 600, out);
out.flush();
out.close();
} catch (Exception e) {
e.printStackTrace();
}
}
});
y cómo lo hacen aparece un mensaje en el que está escrito "Su imagen se guardó." como una alerta, pero por 2 segundos y luego desaparece
¿Qué tal Toast.makeText (esto, R.string.your_message, Toast.LENGTH_SHORT) .show(); –
bien, gracias =) –