Java tutorial
//package com.java2s; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import android.app.Activity; import android.net.Uri; import android.os.Environment; public class Main { private static Activity mActivity; public static void copyBitmapToTempFile(Uri uri) { File picture = new File(Environment.getExternalStorageDirectory() + "/yourName", "temp"); FileOutputStream out = null; InputStream is = null; try { is = mActivity.getContentResolver().openInputStream(uri); out = new FileOutputStream(picture); byte[] buffer = new byte[1024]; while (is.read(buffer) != -1) { out.write(buffer); } is.close(); is = null; out.close(); out = null; } catch (FileNotFoundException e) { } catch (IOException e) { } finally { try { if (is != null) { is.close(); is = null; } if (out != null) { out.close(); out = null; } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } }