0

I mean I want to append my txt in raw file.

I use this but it cant.

FileOutputStream fOut = openFileOutput(R.raw.a, MODE_WORLD_APPEND);
OutputStreamWriter osw = new OutputStreamWriter(fOut); 
Chirag
  • 56,384
  • 29
  • 154
  • 197
Ersin Gülbahar
  • 6,713
  • 15
  • 60
  • 114
  • 1
    I don't know much about Android programming, but don't you need to change the "MODE_WORLD_READABLE" to "MODE_WORLD_WRITEABLE"? – Janman Sep 25 '12 at 18:36
  • @Janman yes it s true but the problem is it is not allow R.raw.a , it is wait for string of path. But what is path? – Ersin Gülbahar Sep 25 '12 at 18:40

2 Answers2

1

Files in raw are packaged with ap. So these are read only files. You cannot modify these files. You need to copy this onto filesystem and then change it.

Edit: Check this post Copying raw file into SDCard? . Add permission

  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

if you are writing to sdcard

Community
  • 1
  • 1
nandeesh
  • 24,530
  • 6
  • 66
  • 77
0

I'm new to android programming, but what I think the problem is that you can't change the R.raw files. However, you should be able to write to an file on the device directly like this:

FileWriter f0 = new FileWriter("file1.txt"); 
f1.write("Hello Ersin!"); 
f1.close(); 

It should also be a lot easier to access and modify files made on the device instead of some created inside the project.

Janman
  • 687
  • 1
  • 9
  • 25