[英]How to create a text file inside the directory that I have created (Android External Storage)
我想在使用代码创建的folder
内创建一个text file
。 我创建了RegUp
。 现在,我需要在RegUp
文件夹中创建一个text file
。
我用来创建文件夹的代码:
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");
}
}
如下所示:
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");
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.