Reputation: 177
here's my problem.
I have a txt file in the /raw folder and I want to write into it. From the Android guide i saw this:
Tip: If you want to save a static file in your application at compile time, save the file in your project res/raw/ directory. You can open it with openRawResource(), passing the R.raw. resource ID. This method returns an InputStream that you can use to read the file (but you cannot write to the original file).
So in my code I did this:
FileOutputStream myFile = openRawResource(R.raw.max_easy, Context.MODE_PRIVATE);
But gives me error in openRawResource()... How do i solve this?
Thank you for the help!
Upvotes: 1
Views: 1940
Reputation: 1006584
I have a txt file in the /raw folder and I want to write into it
That is not possible at runtime. Resources and assets are read-only at runtime.
But gives me error in openRawResource()... How do i solve this?
openRawResource()
is for reading in the resource, and it gives you an InputStream
. You are welcome to write your data to an ordinary file, such as on internal storage.
Upvotes: 4