Reputation: 131
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.
If someone could explain to me either how to open the resource file to a PrintWriter, i'd appreciate it.
Upvotes: 2
Views: 2732
Reputation: 1007369
however I am not sure how to open it so I can use PrintWriter with it.
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.
Upvotes: 2