Java tutorial
//package com.java2s; import android.os.Environment; import android.util.Log; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; public class Main { private final static String LOG_TAG = "Helpers"; private final static String FOLDER_NAME = "Steganography"; public static File saveText(String text) throws IOException { File f; String filename; if (!isExternalStorageWritable()) throw new IOException("Storage not available"); DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); filename = dateFormat.format(new Date()); f = new File(getAlbumStorageDir(FOLDER_NAME), "Message " + filename + ".txt"); FileWriter fw = new FileWriter(f); fw.write(text); fw.close(); return f; } private static boolean isExternalStorageWritable() { String state = Environment.getExternalStorageState(); return Environment.MEDIA_MOUNTED.equals(state); } private static File getAlbumStorageDir(String albumName) { // Get the directory for the user's public pictures directory. File file = new File(Environment.getExternalStorageDirectory(), albumName); if (!file.mkdirs()) { Log.d(LOG_TAG, "Directory not created"); } return file; } }