如何在Android应用程序中编辑资源文件?(Android Studio) [英] How to edit a resource file from within an android app? (Android Studio)
问题描述
我正在创建一个利用日志的android应用.我已经在原始"资源文件夹中放置了一个名为"log.txt"的文件.我已经弄清楚了如何使用 openRawResource
将其打开到输入流,但是我不确定如何打开它,因此可以将它与 PrintWriter
一起使用.
I'm creating an android app that utilizes a log. I've placed a file entitled "log.txt" in the "Raw" resource folder. I have figured out how to open it to an inputstream using openRawResource
, however I am not sure how to open it so I can use PrintWriter
with it.
我还尝试访问在目标设备上预先创建的文件,但没有成功.
I have also tried accessing a file pre-created on the target device, but have not succeeded.
如果有人可以向我解释如何将资源文件打开到PrintWriter,我将不胜感激.
If someone could explain to me either how to open the resource file to a PrintWriter, i'd appreciate it.
推荐答案
但是我不确定如何打开它,因此可以将它与PrintWriter一起使用.
however I am not sure how to open it so I can use PrintWriter with it.
不能.资源在运行时是只读的.欢迎您使用该 InputStream
将资源内容的副本写入文件系统上的文件中(例如,在
You can't. Resources are read-only at runtime. You are welcome to use that InputStream
to write a copy of the resource's contents to a file on the filesystem (e.g., on internal storage), though.
这篇关于如何在Android应用程序中编辑资源文件?(Android Studio)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!