Onclick of button Call Method to Save your Image to SDcard:
SaveImage(bitmap);
Saving Image to SdCard:
private void SaveImage(Bitmap finalBitmap) {
String root = Environment.getExternalStorageDirectory().toString();
File myDir = new File(root + "/demo_images");
myDir.mkdirs();
Random generator = new Random();
int n = 10000;
n = generator.nextInt(n);
fname = "Image-"+ n +".jpg";
File file = new File (myDir, fname);
// Below code will give you full path in TextView
> txtPath1.setText(file.getAbsolutePath());
if (file.exists ()) file.delete ();
try {
FileOutputStream out = new FileOutputStream(file);
finalBitmap.compress(Bitmap.CompressFormat.JPEG, 90, out);
out.flush();
out.close();
} catch (Exception e) {
e.printStackTrace();
}
}
For getting Image from SdCard:
Bitmap bitmap = BitmapFactory.decodeFile(file.getAbsolutePath());
imageview.setImageDrawable(bitmap);
For Storing Image to Internal Memory:
Saving and Reading Bitmaps/Images from Internal memory in Android