如何以编程明确的应用数据 [英] How to programatically clear application data
问题描述
我开发一个Android应用程序(使用Robotium)自动测试。为了保证测试的一致性和可靠性,我想先从每个测试干净的状态(根据测试的应用程序)。为了做到这一点,我需要清除应用程序的数据。这可以手动设置/应用程序/管理应用程序来完成/ [我的应用程序] /清除数据。
I am developing automated tests for an android application (using Robotium). In order to ensure the consistency and reliability of tests, I would like to start each test with clean state (of the application under test). In order to do so, I need to clear the app data. This can be done manually in Settings/Applications/Manage Applications/[My App]/Clear data
什么是推荐的方式来完成这件事编程?
What is the recommended way to get this done programatically?
推荐答案
您可以使用软件包管理器工具来清除在应用程序设置,安装的应用程序数据(类似于pressing清除数据按钮,在您的设备)。 因此,使用亚行,你可以这样做:
You can use the package-manager tool to clear data for installed apps (similar to pressing the 'clear data' button in the app settings on your device). So using adb you could do:
adb shell pm clear my.wonderful.app.package
这篇关于如何以编程明确的应用数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!