Android: Image save to location

后端 未结 1 1067
别跟我提以往
别跟我提以往 2021-01-06 13:03

I\'m working on displaying a set of images, then if the users wishes, to have the ability to save the image to the SD card. I need help saving them to external storage. Can

相关标签:
1条回答
  • 2021-01-06 14:00

    Hi I haven't used the code I'm giving you as part of an application but I did use this to debug bitmaps generated at runtime in one of my apps.

    try {
               FileOutputStream out = new FileOutputStream("/sdcard/test2.png");
               mBitmap.compress(Bitmap.CompressFormat.PNG, 90, out);
            } catch (Exception e) {
               e.printStackTrace();
            }
    

    with this code as long as you have a bitmap, you just need this + the manifest permission

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    

    Hope that does the trick for you

    Jason

    0 讨论(0)
提交回复
热议问题