我试图将图片保存到WathsappIMG文件夹中,但当我前往安卓的图库时,我找不到这张图片。然而,从ES文件浏览器中可以看到该目录下的图片。
我试图将图片保存到WathsappIMG文件夹中,但当我前往安卓的图库时,我找不到这张图片。然而,从ES文件浏览器中可以看到该目录下的图片。
OutputStream output;
// Find the SD Card path
File filepath = Environment.getExternalStorageDirectory();
// Create a new folder in SD Card
File dir = new File(filepath.getAbsolutePath()
+ "/WhatSappIMG/");
dir.mkdirs();
// Retrieve the image from the res folder
BitmapDrawable drawable = (BitmapDrawable) principal.getDrawable();
Bitmap bitmap1 = drawable.getBitmap();
// Create a name for the saved image
File file = new File(dir, "Wallpaper.jpg" );
try {
output = new FileOutputStream(file);
// Compress into png format image from 0% - 100%
bitmap1.compress(Bitmap.CompressFormat.JPEG, 100, output);
output.flush();
output.close();
}
catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}