- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我已使用 File 对象和各种 FileReaders/Writers 和 BufferedReaders/Writers 将我的应用程序的所有数据放在 SD 卡的目录和子目录中。
我突然想到并非所有设备都有 SD 卡,所以我现在有 4 个问题。
有谁知道目前运行 android 的手机中有多少比例没有安装 SD 卡?
有没有一种方法可以允许我自己操作手机内存(应用程序目录)的文件结构,就像我可以在 SD 卡上操作一样?
我是否必须重新实现所有代码才能使用 openFileOutput() 而不是 createNewFile() 在我的应用中复制 SD 卡文件行为?
为什么 SD 与应用程序目录的文件访问首先存在差异?
最佳答案
1)does anyone know off hand roughly what percentage of handsets running android currently don't implement SD cards?
即使手机可以支持SD卡,也不代表它在给定时刻确实支持,因为PC可以移除或安装SD卡访问或有数百个其他原因。所以,不要把任何重要的东西放在那里。
2)is there a way I can give myself permission to manipulate the file structure of the phones internal memory (application directory) in the same why I can on the SD card?
内存文件不能有任何层级结构,如果你的文件名里面有路径分隔符,openFileOutput()
会给你异常。除此之外,您可以在 /data/data/com.your.app/files
目录中放置多少文件没有限制。而且您不需要任何特定权限即可在那里创建/打开文件。
3)will I have to re-implement all of my code in order to duplicate the SD card file behavior in my app using openFileOutput() instead of createNewFile()?
我不会。基本上,应用程序的所有小文件和/或生命关键文件都进入内存,所有大文件和非必需文件(图像、视频?)都进入 SD 卡。不会有冲突,您的应用程序可以完美启动,如果 SD 卡不可用,请提示。
关于android - context.openFileOutput() 与 file.createNewFile() 相比?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10543963/
我正在将数据写入 Android 应用程序中的 xml 文件。我查找了如何正确执行文件 IO 并发现我需要使用 openFileOutput。据我所知,我的代码没有任何问题,但它不断在我在以下代码中包
我正在尝试使用不是 Activity 类的类中的 openFileOutput。当我写下面的东西时,它给了我空指针异常- try { Context con = null;
我正在逐步调试以下代码 fragment ,它不会按预期创建或读取文件,也不会引发任何异常。这位于我的应用程序的主要 Activity 中。这些代码行有什么问题吗? public void onCli
我的应用程序权限有问题。我的应用似乎没有在存储上创建文件的权限。 String FILENAME = "hello_file"; String string = "hello world!"; Fil
首先,我在 Main Activity 中编写了一些方法,但我决定它们应该是一个类。 这是我的代码... openFileOutput 和 openFileInput 未定义。任何想法??也许它应该是
这是我本周的菜鸟问题。我正在寻找更多的一般猜测而不是特定代码,也许希望 Android 人员正在关注并纠正这一点: Context.openFileOutput 的 SDK 文档说: Open a p
我想知道使用 context.openFileOutput() 写入文件的实际路径(在存储中),如下所示(跳过异常(exception))。 public static void writeObjec
我正在尝试使用 Wifi 将文件复制到 Android 设备。对于我无法告诉的文件创建工作,但我无法在任何地方找到它...... 我尝试在 Eclipse 上使用 DDMS,但是数据文件夹中没有任何内
我创建了一个程序,用户可以在其中创建一个arrayList,然后将该列表保存到存储设备上的一个文本文件中。我使用了来自 https://developer.android.com/training/b
我创建了一个静态处理程序来从监听传入蓝牙数据的线程接收数据。此处理程序调用:measure_finish2() 并且此方法调用一个名为:measure_finish() 的非静态方法,在最后一个方法中
我像这样将我的文件保存到应用程序的私有(private)内部存储中,然后将该文件传递到 Uri 中,以便我可以将其作为其他 Activity 的结果返回 String filename = new S
这个问题在这里已经有了答案: What file system path is used by Android's Context.openFileOutput()? (4 个答案) 关闭 9 年前
我创建了文件,即 txt 文件,并使用 openFileOutput fn 将值存储到其中。此函数在 data/data/app_name/files 文件夹中创建 txt 文件。现在我正在尝试将 .
我用过很多次openFileOutput。 例子: FileOutputStream fileOutputStream = openFileOutput(fileName, Context.MODE_
我目前正在构建一个应用程序,用户将随着时间的推移生成数据,如果他/她有互联网连接,则将其传输到网络。但是,如果他没有网络访问权限,我需要将这些数据存储在手机中,直到用户恢复他的访问权限,那时我需要恢复
我正在尝试将字符串写入文件,为此我使用 openFileOutput: FileOutputStream fOut = openFileOutput("samplefile.txt",Contex
作为一名 Android 开发新手,我遇到了一些奇怪的问题。我想创建一个类,它方法其他类- Activity -任何可以用于以某种特殊方式处理文件的类。假设为了简单起见,我们将记录一些内容。如果我在
我正在尝试让我的 rss 阅读器保存 URL 地址,以便在重新打开时保存它。但出于同样的原因,openFileOutput 和 openFileInput 是红色的,它表示它无法解析方法。 我们的教授
我正在尝试保存 html 文件。我有扩展 AsyncTask 的类 public class DownloadBook extends AsyncTask { 在这个类中,我有这个方法: privat
我阅读了 openFileOutput 的文档,并看到“打开与此上下文的应用程序包关联的私有(private)文件进行写入。如果文件尚不存在,则创建该文件”( http://developer.and
我是一名优秀的程序员,十分优秀!