android圖片 大自然的搬運工

android中保存Bitmap图片到指定文件夹中的方法 

/** 保存方法 */

 public void saveBitmap() {

  Log.e(TAG, "保存图片"); 

  File f = new File("/sdcard/namecard/", picName); 

  if (f.exists()) {  

 f.delete();  

}  try {   

FileOutputStream out = new FileOutputStream(f); 

   bm.compress(Bitmap.CompressFormat.PNG, 90, out);  

 out.flush(); 

   out.close();  

 Log.i(TAG, "已经保存"); 

  } catch (FileNotFoundException e) {   // TODO Auto-generated catch block   e.printStackTrace(); 

  } catch (IOException e) { 

   // TODO Auto-generated 

catch block   e.printStackTrace();  } }

 在这里还需要两个权限:


你可能感兴趣的:(android圖片 大自然的搬運工)