How to run android app in emulator by rewriting old databases?

江枫思渺然 提交于 2019-12-20 06:26:14

问题


When I always run app to test in emulator from Eclipse , by default it never uninstalls previous one. It will maintain previous copy of database and files of the same app and run a new compiled code.

What if I want to remove all app related files, databases every time I compile and run it to test? Any settings for this in Eclipse ? I want to avoid the step of manually uninstalling it before every run. Thanks.


回答1:


You can have a command prompt window open, and before launching, execute:

adb uninstall your.project.package

when using adb install with the -r modifier, the app re-installs and its data is saved. I haven't found any place in Eclipse to change this configuration, but I think this is done inside the SDK's Ant tasks. Take a look at this class for more information




回答2:


You can accomplish part of this using a database version in any SQLiteOpenHelper subclasses, then overriding onUpgrade to drop all tables. Actually, I suppose onUpgrade could also delete known files.




回答3:


Does the "Wipe user data" under run configurations target tab wipe everything for you? I'm not 100% what it wipes before running the app, but I suspect it clears out all the data. You might give it a try.



来源:https://stackoverflow.com/questions/4774526/how-to-run-android-app-in-emulator-by-rewriting-old-databases

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