App is more and more humanized: The interface is beautiful, service diversification, operation is very convenient. For example, when we use the app, we find that there is a comparison of the pictures to save to the phone, just click on the app to provide the Save button on it. So how does this picture be saved to the local implementation?
Saving the picture is simple, as follows:
/** Default File Save path First */
private static final String save_pic_path=environment.getexternalstoragestate (). Equalsignorecase (Environment.media _mounted)? Environment.getexternalstoragedirectory (). GetAbsolutePath (): "/mnt/sdcard";//Save to SD card
private static final String Save_real_path = save_pic_path+ "/good/savepic";//exact location of the Save
Here is the method of saving, passing in the parameters can be:
public static 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, N, BOS);
Bos.flush ();
Bos.close ();
}
This is preserved, but sometimes obviously saved, why do you not see it when you enter the album? Anyway, I encountered such a problem, the original we in the preservation of success, but also to send a system broadcast notification phone has a picture update, broadcast as follows:
Intent Intent = new Intent (intent.action_media_scanner_scan_file);
Uri uri = uri.fromfile (file);
Intent.setdata (URI);
Context.sendbroadcast (intent);//The purpose of this broadcast is to update the library, send this broadcast into the album will be able to find your saved pictures! , remember to upload your updated file oh
Android saves images locally and can be displayed in albums