Save Image Locally In Android
I am new in Android. I want to store my image(which is chosen from gallery or tack picture from Camera) locally(i.e. SharedPreferences). I want to save my images till application w
Solution 1:
call this function for save..
void saveImage() {
File myDir=new File("/sdcard/saved_images");
myDir.mkdirs();
String fname = "Image.jpg";
File file = new File (myDir, fname);
if (file.exists ()) file.delete ();
try {
FileOutputStream out = new FileOutputStream(file);
finalBitmap.compress(Bitmap.CompressFormat.JPEG, 90, out);
out.flush();
out.close();
final AlertDialog alertDialog = new AlertDialog.Builder(this).create();
alertDialog.setTitle("Save");
alertDialog.setMessage("Your drawing had been saved:)");
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
return;
}
});
alertDialog.show();
} catch (Exception e) {
e.printStackTrace();
}
}
Post a Comment for "Save Image Locally In Android"