Here you can find the source of saveBitmapToPath(Context ctxt, String path, String filename, Bitmap bm)
public static void saveBitmapToPath(Context ctxt, String path, String filename, Bitmap bm)
//package com.java2s; /******************************************************************************* * Rumblefish Mobile Toolkit for Android * //from w ww.j av a 2 s .c om * Copyright 2013 Rumblefish, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Use of the Rumblefish Sandbox in connection with this file is governed by * the Sandbox Terms of Use found at https://sandbox.rumblefish.com/agreement * * Use of the Rumblefish API for any commercial purpose in connection with * this file requires a written agreement with Rumblefish, Inc. ******************************************************************************/ import java.io.File; import java.io.FileOutputStream; import android.content.Context; import android.graphics.Bitmap; import android.graphics.Bitmap.CompressFormat; import android.os.Environment; public class Main { public static void saveBitmapToPath(Context ctxt, String path, String filename, Bitmap bm) { File directory = new File( Environment.getExternalStorageDirectory(), path); if (!directory.exists()) directory.mkdir(); File lastFile = new File(directory, filename); try { if (lastFile.createNewFile() == false) { lastFile.delete(); lastFile.createNewFile(); } FileOutputStream ostream = new FileOutputStream(lastFile); bm.compress(CompressFormat.JPEG, 100, ostream); ostream.close(); } catch (Exception e) { } } }