Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // get the path to sdcard
- File sdcard = Environment.getExternalStorageDirectory();
- // to this path add a new directory path
- File dir = new File(sdcard.getAbsolutePath() + "/thieumao/");
- // create this directory if not already created
- dir.mkdir();
- // create the file in which we will write the contents
- File file = new File(dir, "name.txt");
- FileOutputStream os;
- try {
- os = new FileOutputStream(file);
- String data = "Messages";
- try {
- os.write(data.getBytes());
- } catch (IOException e) {
- e.printStackTrace();
- }
- try {
- os.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- }
Advertisement
Add Comment
Please, Sign In to add comment