我想在text file
设备的外部存储器中使用代码创建的folder
内创建android
。使用我的代码,我创建了folder
。现在,我需要知道如何在相同的text file
中创建一个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");
}
}
答案 0 :(得分:0)
如下所示:
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");
}
}