我想在内部存储器中的文件夹在我的应用程序存储音频文件,然后检查是否存在做一些操作。 如何使这个folde,其中路径,以及如何再次获得这些文件?
解决方案 文件MYDIR = context.getDir(MYDIR,Context.MODE_PRIVATE); //创建一个内部目录;
文件fileWithinMyDir =新的文件(MYDIRMYFILE); //获取目录中的文件。
FileOutputStream中出=新的FileOutputStream(fileWithinMyDir); //使用流像往常一样写入到文件
有关内部删除文件:
如果(新的文件(路径/到/文件)。删除()){
//删除
} 其他 {
//不会被删除
}
I want to make a folder in the Internal Memory in my application to store Audio Files,then check if the exist to do some operations. How to make this folde, in which path, and how to retrieve these files again?
解决方案File mydir = context.getDir("mydir", Context.MODE_PRIVATE); //Creating an internal dir;
File fileWithinMyDir = new File(mydir, "myfile"); //Getting a file within the dir.
FileOutputStream out = new FileOutputStream(fileWithinMyDir); //Use the stream as usual to write into the file
For deleting a file from internal :
if (new File("path/to/file").delete()) {
// Deleted
} else {
// Not deleted
}