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

 ̄綄美尐妖づ 提交于 2019-11-27 13:46:19

问题


How to write to .txt file in assets folder.

How to get path assets folder ?


回答1:


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.




回答2:


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.




回答3:


Not possible,

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




回答4:


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.



来源:https://stackoverflow.com/questions/9781809/save-a-txt-file-to-the-assets-folder-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!