Java tutorial
//package com.java2s; import java.io.File; import java.io.FileOutputStream; public class Main { /** * Write file to sdcard * @param dir * @param bt * @return */ public synchronized static File writeToSDCard(String dir, byte[] bt) { File file = null; try { file = new File(dir); if (file.exists()) { return file; } file.createNewFile(); FileOutputStream fos = new FileOutputStream(file); fos.write(bt); fos.close(); return file; } catch (Exception e) { if (file.exists()) { file.delete(); } e.printStackTrace(); } return null; } }