Copy file to assets folder

こ雲淡風輕ζ 提交于 2019-12-10 12:46:36

问题


After searching 1 hour i do not found any solution to my problem.

I want to move a file from sdcard to assets folder and also overwrite the existing file in assets folder (both file are sqlite database have same name with just a little difference in data )

??


回答1:


Actually, The behaviour of the android .apk file is read only so the directory structure which are in that apk file follows the same, So no one can write this files or make changes on that at runtime,that's why You can't make a changes in /asset folder at runtime. you can read file from it (means copy files which are available in asset to any internal storage or /sdcard but not write it to vice-versa)

Its apply on all the directories which are build in .apk files. As per docs.




回答2:


Assets folder are not Writable it is only readable so you cant copy from sdcard to assets, yes you can copy from assets to sdcard




回答3:


If you want other apps not to access your database then what you can do is

  1. Download the database from website. create a temp database also in app directory.
  2. getDatabasePath() this will give you the path of the dummy database you have created now replace this with the one you downloaded.

PS.: User and apps having root access still able to access it and you cant do anything in that scenario



来源:https://stackoverflow.com/questions/8399505/copy-file-to-assets-folder

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