How to attach .db file with another .apk android

十年热恋 提交于 2019-12-08 12:39:13

问题


i am making dictionary and i have so much data to load. I want that i create a project which first load the dictionary words in database and the after i use this .db file in my 2nd project which is dictionary project.

But i don't know how to get the .db file and copy it and paste it into my assets folder.


回答1:


Well, yopu cant simply copy any files from one private storage, to another. I suppose you can archive this using different ways, for example:

1) Copy your .db file to SD card by first app, and copy it back to private storage by the second app.

2) You can use ContentProvider to share private data between 2 different applications without moving it on SD card.

You can'not get direct access to assest or any other data folder of different application. Good luck!




回答2:


You can get resources from other package with PackageManager.getResourcesForApplication() method. Also you can share user id between your apps and sign them with share sertificate. In this case you can even share code base. +@Evos' suggestions.

I think share user id is your choise.

You can find examples and more info in this post and here.




回答3:


Open Your previous project them open DDMS tab ,then go on path data--->data---->your project---->databases--->.db file now select that file and click on top right corner of screen here is a buuton to pull file from device to PC so click on that now a file dialog will appear select location to save file , now ok....this action will save your .db file on your selected location now you can copy this file and put this file in your new projects assets folder and then use it.



来源:https://stackoverflow.com/questions/14373380/how-to-attach-db-file-with-another-apk-android

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