Here you can find the source of writeNewFile(String filePath, String fileContents)
public static void writeNewFile(String filePath, String fileContents)
//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();//ww w . j a v a 2s. c om } 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); } } }