Java tutorial
//package com.java2s; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import android.content.Context; public class Main { public static boolean writeToFile(Context ctx, String strContent, String filename) { boolean bReturn = true; FileOutputStream osw = null; try { //Make sub directories if needed String[] split = filename.split(File.separator); String file = split[split.length - 1]; String path = filename.substring(0, filename.indexOf(file)); if (path != "") new File(ctx.getFilesDir() + File.separator + path).mkdirs(); File outputFile = new File(ctx.getFilesDir() + File.separator + filename); osw = new FileOutputStream(outputFile); osw.write(strContent.getBytes()); osw.close(); } catch (Exception e) { e.printStackTrace(); bReturn = false; } finally { try { if (osw != null) osw.close(); } catch (IOException e) { e.printStackTrace(); } } return bReturn; } }