为什么小弟我的bit地图不能保存到sd卡
为什么我的bitmap不能保存到sd卡
代码如下:
private void saveMyBitmap(Bitmap bitmap,String photoName){
String path = Environment.getExternalStorageDirectory()+"\\";
File file = new File(path+photoName+".jpg");
try {
file.createNewFile();
FileOutputStream fos = new FileOutputStream(file);
bitmap.compress(Bitmap.CompressFormat.JPEG,75,fos);
System.out.println(path);
fos.flush();
fos.close();
} catch (Exception e) {
// TODO Auto-generated catch block
System.out.println(e.getMessage());
e.printStackTrace();
}
}
------解决方案--------------------
LZ加写sdcard权限了吗?
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
更多参考:http://dalvik.co.cc
------解决方案--------------------
AndroidManifest.xml添加权限
代码如下:
private void saveMyBitmap(Bitmap bitmap,String photoName){
String path = Environment.getExternalStorageDirectory()+"\\";
File file = new File(path+photoName+".jpg");
try {
file.createNewFile();
FileOutputStream fos = new FileOutputStream(file);
bitmap.compress(Bitmap.CompressFormat.JPEG,75,fos);
System.out.println(path);
fos.flush();
fos.close();
} catch (Exception e) {
// TODO Auto-generated catch block
System.out.println(e.getMessage());
e.printStackTrace();
}
}
------解决方案--------------------
LZ加写sdcard权限了吗?
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
更多参考:http://dalvik.co.cc
------解决方案--------------------
AndroidManifest.xml添加权限
- Java code
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>