<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"></uses-permission>
public String sdCardDir = Environment.getExternalStorageDirectory() + "/fingerprintimages/";
private void saveBitmap(Bitmap bitmap) { try { File dirFile = new File(sdCardDir); if (!dirFile.exists()) { //如果不存在,那就建立这个文件夹 dirFile.mkdirs(); } File file = new File(sdCardDir, tmplName + ".jpg"); FileOutputStream fos = new FileOutputStream(file); bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fos); fos.flush(); fos.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } // 把文件插入到系统图库 try { MediaStore.Images.Media.insertImage(this.getContentResolver(), file.getAbsolutePath(), fileName, null); } catch (FileNotFoundException e) { e.printStackTrace(); } // 通知图库更新 sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.parse("file://" + "/sdcard/namecard/"))); }