Android: how to clear app cache and keep user data via adb?

落爺英雄遲暮 提交于 2019-11-30 08:36:17

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.

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, which isn't affected by this). It worked for me.

Edit: Of course, your device's adb must be set up to have root access (in Cyanogen, you can enable it).

Edit: @running-codebase pointed out in the comments, that if your application is compiled with a debug key, you can also use run-as command in adb's shell. So it would look like this: adb shell run-as <app's package> rm -rf /data/data/<app's package>/cache/* This method does not require root.

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