Java tutorial
//package com.java2s; //License from project: Apache License import java.io.File; import java.io.FileOutputStream; import java.io.IOException; public class Main { public static boolean writeToSdcard(byte[] data, String path, String fileName) { FileOutputStream fos = null; try { File filePath = new File(path); if (!filePath.exists()) { filePath.mkdirs(); } File file = new File(path + fileName); if (file.exists()) { file.delete(); } fos = new FileOutputStream(file); fos.write(data); fos.flush(); return true; } catch (Exception e) { return false; } finally { try { if (fos != null) fos.close(); } catch (IOException e) { e.printStackTrace(); } } } }