private static final String SAVE_PIC_PATH = Environment.getExternalStorageState().equalsIgnoreCase(Environment.MEDIA_MOUNTED) ? Environment.getExternalStorageDirectory().getAbsolutePath() :
"/mnt/sdcard";//保存到SD卡
private static final String SAVE_REAL_PATH = SAVE_PIC_PATH + "/good/savePic";
//保存的确切位置,根据自己的具体需要来修改
public void saveFile(Bitmap bm, String fileName, String path) throws IOException {
String subForder = SAVE_REAL_PATH + path;
File foder = new File(subForder);
if (!foder.exists()) {
foder.mkdirs();
}
File myCaptureFile = new File(subForder, fileName);
if (!myCaptureFile.exists()) {
myCaptureFile.createNewFile();
}
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(myCaptureFile));
bm.compress(Bitmap.CompressFormat.JPEG, 80, bos);
bos.flush();
bos.close();
Toast.makeText(this, "保存成功", Toast.LENGTH_SHORT).show();
MediaScannerConnection.scanFile(this, new String[]{SAVE_REAL_PATH+ "/" + fileName}, null, new MediaScannerConnection.OnScanCompletedListener() {
@Override
public void onScanCompleted(String path, Uri uri) {
Log.e( "onScanCompleted: ", path);
Log.e( "onScanCompleted: ", uri.toString());
}
});
Intent intent = new Intent(Intent.ACTION_MEDIA_MOUNTED); //这是刷新SD卡
// Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); // 这是刷新单个文件
Uri uri = Uri.fromFile(new File(SAVE_REAL_PATH));
intent.setData(uri);
sendBroadcast(intent);
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有