19

How to write to .txt file in assets folder.

How to get path assets folder ?

Sardor Dushamov
  • 1,665
  • 3
  • 17
  • 44

4 Answers4

27

You can't. The assets folder is read-only at runtime.

Pick a different location to save your data, see Data Storage for more information.

15

The path of assets folder is file:///android_asset But this is read-only.

The assets folder is like folders res, src, gen, etc. These are all useful to provide different files as input to build system to generate APK file for your app.

All these are read-only while your app is running. At run-time you can only write to SD card.

I hope you understand my answer.

Yugandhar Babu
  • 10,311
  • 9
  • 42
  • 67
4

Not possible,

Better you choose internal storage to save your txt file. Internal Storage. Hope this will help you to understand.

RAAAAM
  • 3,378
  • 19
  • 59
  • 108
  • how to save users login and password in text file? in user.txt login password login1 password1 login2 password2 .... – Sardor Dushamov Mar 20 '12 at 08:34
  • 2
    why should you use txt file, better option write it on XML file. so that you make flexibility whatever you want. – RAAAAM Mar 20 '12 at 09:41
2

No you can't do this, because of if you read and write both at runtime then everything could be change and application will behave unexpected which could be harmful or may be crashed. i suggest you to use internal memory, sqlite and app SharedPreferences etc.