I’m wondering how to save an image to user’s sdcard through a button click.
Could some one show me how to do it. The Image is in .png format and it is stored in the drawable directory. I want to program a button to save that image to the user’s sdcard.
I’m wondering how to save an image to user’s sdcard through a button click.
Share
The process of saving a file (which is image in your case) is described here: save-file-to-sd-card
Saving image to sdcard from drawble resource:
Say you have an image namely ic_launcher in your drawable. Then get a bitmap object from this image like:
The path to SD Card can be retrieved using:
Then save to sdcard on button click using:
Don’t forget to add
android.permission.WRITE_EXTERNAL_STORAGEpermission.Here is the modified file for saving from drawable: SaveToSd
, a complete sample project: SaveImage