public boolean saveMyBitmap(Bitmap bmp, String bitName) throws IOException {
boolean flag = false;
if
(Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED))
{
//
获得存储卡的路径
String sdpath = Environment.getExternalStorageDirectory() +
"/";
String mSavePath = sdpath + "lzrc/imgs";
File f = new
File(mSavePath, bitName);
f.createNewFile();
FileOutputStream fOut = null;
try {
fOut = new
FileOutputStream(f);
bmp.compress(Bitmap.CompressFormat.PNG, 100,
fOut);
flag = true;
} catch (FileNotFoundException e) {
e.printStackTrace();
}
try {
fOut.flush();
} catch (IOException e) {
e.printStackTrace();
}
try {
fOut.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return flag;
}
原文地址:http://www.cnblogs.com/lucoo/p/3716168.html