Last active
February 27, 2020 06:27
-
-
Save Gkemon/e2e50483ce2618b487d3da8b90941d20 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String msg="My name is emon"; | |
String directory_path = Environment.getExternalStorageDirectory().getPath(); | |
File file = new File(directory_path,"/Android"); //"/Android" is the folder name | |
if(!file.exists()){ | |
file.mkdir(); | |
} | |
if (!file.exists()) { | |
file.createNewFile(); | |
} | |
if (file.exists()) { | |
try{ | |
FileWriter writer = new FileWriter(new File( file,"file.txt")); | |
writer.append(msg); | |
writer.flush(); | |
writer.close(); | |
Toast.makeText(this,"File is created",Toast.LENGTH_LONG).show(); | |
}catch (Exception e){ | |
e.printStackTrace(); | |
Toast.makeText(this,"File is not created "+e.getMessage(),Toast.LENGTH_LONG).show(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment