Java tutorial
//package com.java2s; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; import android.os.Environment; public class Main { private static String folderName = "myNotifications"; /*** * write a line to the log file * * @param line */ public static void writeToLog(String line) { DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); Date date = new Date(); File f = new File(Environment.getExternalStorageDirectory() + File.separator + folderName); boolean success = true; if (!f.exists()) { success = f.mkdir(); } if (success) { // Do something on success File fileDir = new File(f, dateFormat.format(date) + ".txt"); try { FileOutputStream os = new FileOutputStream(fileDir, true); os.write(line.getBytes()); os.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } }