Save image to storage

internal storage:

private void saveInternalImg(Bitmap myBitmap){
ContextWrapper wrapper = new ContextWrapper(getApplicationContext());
File file = wrapper.getDir(“Images”,MODE_PRIVATE);
file = new File(file, “internalFileName”+”.jpg”);
Log.w(TAG,”saveInternalImg.file:”+file);
try{
OutputStream stream = null;
stream = new FileOutputStream(file);
myBitmap.compress(Bitmap.CompressFormat.JPEG,100,stream);
stream.flush();
stream.close();
}catch (Exception e) {
e.printStackTrace();
}
Uri savedImageURI = Uri.parse(file.getAbsolutePath());
Log.w(TAG,”saveInternalImg.savedImageURI:”+savedImageURI);
context = getApplicationContext();
Toast toast = Toast.makeText(context, “Uri:”+savedImageURI, Toast.LENGTH_SHORT);
toast.show();
Media.insertImage(getContentResolver(), myBitmap, “filee1” , “”);
}

https://android–code.blogspot.com/2015/09/android-how-to-save-image-to-internal.html

external storge:

https://developer.android.com/training/basics/data-storage/files.html

https://github.com/commonsguy/cw-omnibus/blob/master/Camera/Content/app/src/main/java/com/commonsware/android/camcon/CameraContentDemoActivity.java

add to gallery:

MediaStore.Images.Media.insertImage(getContentResolver(), yourBitmap, yourTitle , yourDescription);

https://stackoverflow.com/questions/17674634/saving-and-reading-bitmaps-images-from-internal-memory-in-android

/storage/emulated/0/

ref:-

https://stackoverflow.com/questions/15662258/how-to-save-a-bitmap-on-internal-storage

http://android-er.blogspot.com/2011/10/save-and-read-bitmap-in-internal.html

http://www.codexpedia.com/android/android-download-and-save-image-internally/

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s