您的位置:首页 > 其它

保存图片到SD卡

2015-08-18 23:39 477 查看

添加SD卡写权限

方法

public void saveMyBitmap(String bitName, Bitmap mBitmap) {
    File f = new File("/sdcard/" + bitName + ".png");
    try {
        f.createNewFile();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        DebugMessage.put("在保存图片时出错:" + e.toString());
    }
    FileOutputStream fOut = null;
    try {
        fOut = new FileOutputStream(f);
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }
    mBitmap.compress(Bitmap.CompressFormat.PNG, 100, fOut);
    try {
        fOut.flush();
    } catch (IOException e) {
        e.printStackTrace();
    }
    try {
        fOut.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: