Resources aren't even IN the filesystem. They're packaged up in the .apk file, and are read-only.
You CAN write to the application's private storage area. This will work even if the device does not have an SD card. However, this storage is limited; it may be better for you to use the SD card. In your example, you give it a path that refers to several levels of directory that don't exist - and openFileOutput() is documented as taking a file NAME, not a path. But you can use getDir(name, mode) to create a directory (and control access) and then create files in that via the normal Java APIs. If you choose to put it on the SD card, follow TreKing's advice, except the API is called Environment.getExternalStorageDirectory(). You can do File myDir = new File(Environment.getExternalStorageDirectory(), getPackageName()) mydir.mkdir(); Writer out = new FileWriter(myDir); But since you seem to be concerned about the large amount of data, you may want to change how you approach it. The resource can be the default data, and you put additional data or new data that replaces it in a file. Your application would first consult the file, and if not found, it would then consult the resource. This would avoid the need to copy the resource out into the filesystem to modify it. On Mar 12, 6:07 am, RV <[email protected]> wrote: > Hi, > I am stuck on this for a very long. > I have my txt file in res/raw/myfile.txt. > I want to append some text into this file. But I am unable to do so. > I used the code as follows: > > FileOutputStream out = context.openFileOutput( > "res/raw/myfile.txt", > > Context.MODE_WORLD_WRITEABLE > | > Context.MODE_APPEND); > > OutputStreamWriter osw = new > OutputStreamWriter(out); > > osw.write(entry); > osw.flush(); > osw.close(); > > It is not giving any error but also do nothing to my file. > > Also How could I edit only the 1st line of my file. (my file contain > huge data.) > > Any help will be appreciated. > > Thank you > > RV -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

