String path = getFilesDir().getAbsolutePath() + "/images/";
File filePath = new File(path);
if (!filePath.exists()) {
filePath.mkdir();
}
File file = new File(path + "picture");
fl = new SettingFileObserver(file, ACCESS);
fl.startWatching();
private File saveBitMapToFile(Bitmap bitmap, String fileName) {
Log.e("SettingFileObserver", "saveBitMapToFile bitmap=" + bitmap);
if (bitmap == null) {
return null;
}
String path = getFilesDir().getAbsolutePath() + "/images/";
File filePath = new File(path);
if (!filePath.exists()) {
filePath.mkdir();
}
try {
File file = new File(path, fileName);
FileOutputStream fileOutputStream = new FileOutputStream(file);
BufferedOutputStream bos = new BufferedOutputStream(fileOutputStream);
bitmap.compress(Bitmap.CompressFormat.PNG, 80, bos);
bos.flush();
bos.close();
Log.e("SettingFileObserver", "saveBitMapToFile file=" + file);
return file;
} catch (FileNotFoundException ex) {
Log.e("SettingFileObserver", "file not found=" + ex);
} catch (IOException ex) {
Log.e("SettingFileObserver", "IOException=" + ex);
}
return null;
}
【无标题】
最新推荐文章于 2024-09-14 15:55:09 发布