Android的:如何清除应用程序缓存,并通过亚行保持用户数据?
我运行在一个Android应用程序的一些自动化的测试(与蠡-机器人),我需要以编程方式触发一个明确的应用程序的缓存,而不是用户数据。
I'm running some automated tests (with calabash-android) on an Android app and I need to programatically trigger a clear of the app's cache, but not user data.
我发现,亚行外壳时明确
解决方案是不够的,因为它会清除用户数据(包括登录信息)。
I found that the adb shell pm clear
solution is not adequate, since it clears user data (which includes login details).
有没有办法实现这种内外兼修的应用程序(即没有code的变化)?
Is there any way to achieve this externally to the app (i.e. without code changes)?
我一直在探索的 /数据/数据/<应用程序的包>
文件夹,发现一个缓存
文件夹内,其中载有我想要清除缓存应用程序缓存的文件。然后,从亚行外壳
我删除的内容,以及应用程序的缓存被重置。
I've been exploring the /data/data/<app's package>
folder, and found a cache
folder inside, which contained the cached files for the app that I wanted to clear the cache of. Then from adb shell
I deleted the contents, and the app's cache was reset.
最可能的是,你可以运行亚行外壳苏-cRM -rf /数据/数据/&LT;应用程序的封装和GT; /缓存/ *
删除只缓存的的应用程序(应用程序可能有一些自定义的高速缓存)。它为我工作。
Most probably you can run adb shell su -c "rm -rf /data/data/<app's package>/cache/*"
to delete the cache only for the app (the app might have some custom caching). It worked for me.
修改:当然,您的设备的亚行必须设置有 root访问权限(中氰,您可以启用它)。
Edit: Of course, your device's adb must be set up to have root access (in Cyanogen, you can enable it).