Bitmap bitmap = BitmapFactory.decodeResource(getActivity().getResources(),R.drawable.erweima);
String path = FileUtils.instance().getImageCachePath()+"YjttQrCode.jpg";
File file = new File(path);
try {
if (!file.exists()) {
file.createNewFile();
}
FileOutputStream fos = new FileOutputStream(path);
bitmap.compress(Bitmap.CompressFormat.JPEG,100,fos);
fos.flush();
fos.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
Toast.makeText(getActivity(),"保存成功!",Toast.LENGTH_SHORT).show();
Intent intent1 = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
Uri uri = Uri.fromFile(file);
intent1.setData(uri);
getActivity().sendBroadcast(intent1);
大神幫看看我將圖片保存在本地,為什麼在相冊中看不見?在文件夾裡都能看到
你的路徑肯定有問題,參考
http://blog.csdn.net/junjieking/article/details/8260682