在内部存储器中创建文件夹中保存文件,以后再取出来 [英] Creating folder in internal Memory to save files and retrieve them later

查看:167
本文介绍了在内部存储器中创建文件夹中保存文件,以后再取出来的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在内部存储器中的文件夹在我的应用程序存储音频文件,然后检查是否存在做一些操作。 如何使这个folde,其中路径,以及如何再次获得这些文件?

解决方案

 文件MYDIR = context.getDir(MYDIR,Context.MODE_PRIVATE); //创建一个内部目录;
文件fil​​eWithinMyDir =新的文件(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
}

这篇关于在内部存储器中创建文件夹中保存文件,以后再取出来的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆