Java tutorial
//package com.java2s; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStreamWriter; import java.io.Writer; import android.content.Context; public class Main { private static Context matoContext; public static void createAccessLog(String accessLog, String fileName) { makeDirectory(getFilesDir()); FileOutputStream fos = null; try { File newFile = new File(getFilesDir(), fileName); if (!newFile.exists()) { newFile.createNewFile(); } fos = new FileOutputStream(newFile, false); Writer writer = new OutputStreamWriter(fos); writer.write(accessLog); writer.flush(); fos.close(); } catch (IOException e) { e.printStackTrace(); } } public static void makeDirectory(String filePath) { File file = null; try { file = new File(filePath); if (!file.exists()) { file.mkdir(); } } catch (Exception e) { } } public static String getFilesDir() { return matoContext.getFilesDir().getAbsolutePath() + "/qos"; } }