Java tutorial
//package com.java2s; //License from project: BSD License import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStreamWriter; public class Main { public static void logToFile(String filename, String log) { File myFile = new File("/sdcard/SAGETablet/" + filename + ".txt"); try { if (!myFile.exists()) { myFile.createNewFile(); } FileOutputStream fOut = new FileOutputStream(myFile); OutputStreamWriter myOutWriter = new OutputStreamWriter(fOut); myOutWriter.append(log); myOutWriter.close(); fOut.close(); } catch (IOException e) { e.printStackTrace(); } } }