Java tutorial
//package com.java2s; import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import android.util.Log; public class Main { private static final String TAG = "Helpers"; public static void writeNewFile(String filePath, String fileContents) { File f = new File(filePath); if (f.exists()) { f.delete(); } try { // Create file FileWriter fstream = new FileWriter(f); BufferedWriter out = new BufferedWriter(fstream); out.write(fileContents); //Close the output stream out.close(); } catch (Exception e) { Log.d(TAG, "Failed to create " + filePath + " File contents: " + fileContents); } } }