Java tutorial
//package com.java2s; //License from project: Open Source License import java.io.*; import android.content.*; import android.util.Log; public class Main { public static void logGlobalException(Context c, String[] logs) { String dir = c.getExternalFilesDir(null).getParent(); try { File file = new File(dir + "/error_logs.log"); // if file doesnt exists, then create it if (!file.exists()) { file.createNewFile(); } FileOutputStream fos = new FileOutputStream(file, true); for (String log : logs) { fos.write((log + "\n\n").getBytes()); } fos.close(); } catch (IOException ioe) { Log.e("AndroidUtils", "An exception has occured in logGlobalException!"); ioe.printStackTrace(); } } }