在内存中创建文件夹以保存文件并在以后检索它们 [英] Creating folder in internal Memory to save files and retrieve them later

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

问题描述

我想在我的应用程序的内存中创建一个文件夹来存储音频文件,然后检查是否存在以进行一些操作.如何制作这个文件夹,在哪个路径下,如何重新找回这些文件?

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

用于从内部删除文件:

if (new File("path/to/file").delete()) {
  // Deleted
} else {
  // Not deleted
}

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

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