androidbufferedwriter

Android writing to a text file


I have a text file within my raw folder of my app that I intend to use as a simple way to save settings and then read them back when needed. I can read from this file with using the BufferedReader and what comes with it, but I've tried a few different ways to be able to write to this file and none seem to work.

It seems to me that the problem is I never actually get the file, and I assume this is simply because I don't exactly know how I am supposed to give it the correct directory and file name. I've tried all I could come up with, and I tend to get errors like "No such file or directory exists" or "Read-only file system".

This seems to be a very simple problem relating to me just giving the wrong information, so if anybody could point me in the right direction it would be much appreciated.

Thank you, Raphy


Solution

  • For saving settings you should use SharedPreferences rather than coming up with a custom solution.