Method of saving String as TXT file in SD card by Android

  • 2021-09-20 21:30:07
  • OfStack

As shown below:


public static void stringTxt(String str){
  try {
   FileWriter fw = new FileWriter("/sdcard/aaa" + "/cmd.txt");//SD Path in the card 
   fw.flush();
   fw.write(str);
   fw.close();
  } catch (Exception e) {
   e.printStackTrace();
  }
 }

Related articles: