1

I want to create a text file inside the folder that I have created using code. I have created the RegUp. Now I need to create a text file inside the RegUp folder.


Code I used to create the folder:

if(isExternalStorageWritable())
{
      String albumName = "RegUP";
      String fileName = "file.txt";

      File file = new File(Environment.getExternalStorageDirectory(), albumName);

      if (!file.mkdirs())
      {
            Log.e("msg", "Directory not created");
      }
      else
      {
            Log.e("msg", "Directory created");

      }
}
Sajib
  • 57
  • 1
  • 10

1 Answers1

0

like below:

if(isExternalStorageWritable())
{
  String albumName = "RegUP";
  String fileName = "file.txt";

  File file = new File(Environment.getExternalStorageDirectory(), albumName);

  if (!file.mkdirs())
  {
        Log.e("msg", "Directory not created");
  }
  else
  {
        File new_File=new File(file.getPath()+"/"+fileName);//you can now write to this file
        Log.e("msg", "Directory created");

  }


 }
kamyar haqqani
  • 748
  • 6
  • 19