Sardor Dushamov
Sardor Dushamov

Reputation: 1667

Save a (.txt) file to the Assets Folder in Android?

How to write to .txt file in assets folder.

How to get path assets folder ?

Upvotes: 19

Views: 28950

Answers (4)

Ravi Prajapat
Ravi Prajapat

Reputation: 81

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.

Upvotes: 2

RAAAAM
RAAAAM

Reputation: 3380

Not possible,

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

Upvotes: 4

Yugandhar Babu
Yugandhar Babu

Reputation: 10349

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.

Upvotes: 15

user658042
user658042

Reputation:

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.

Upvotes: 27

Related Questions