哪里文件会保存在Android的? [英] Where do files get saved in Android?

查看:105
本文介绍了哪里文件会保存在Android的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个文本文件中写入一些JSON数据的应用程序:

I am developing an application which writes some JSON data in a text file:

FileOutputStream fOut;
fOut = openFileOutput("myfile.txt", MODE_PRIVATE);
OutputStreamWriter osw = new OutputStreamWriter(fOut);
osw.write(myJSONData);

我测试设备上的这个应用程序,当我在我的电脑插上电源,我无法看到文件。你能告诉我它是存储于其中的目录和我需要的文件的操作模式设置为 MODE_WORLD_READABLE 才能看到它吗?

推荐答案

将其插入您的计算机安装它的SD卡,一般。要保存到,获得与 Environment.getExternalStorageDirectory(),然后构造与该文件和您所需的字符串的文件名作为参数一个新的文件SD卡根目录下的文件。这将其保存到你的SD卡,应该是你看到的第一个文件夹时,您将其安装到计算机上。

Plugging it into your computer is mounting it to the SD card, usually. To save to that, get the SD card root directory File with Environment.getExternalStorageDirectory() and then construct a new File with that File and your desired string filename as the arguments. That will save it to your SD card which should be the first folder you see when you mount it on your computer.

顺便说一句,写文/ JSON直奔文件,只需使用 FileWriter的

By the way, for writing text/JSON straight to a file, just use FileWriter.

这篇关于哪里文件会保存在Android的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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