How to clear the app storage and cache?

Mobile Testing, Android App Testing.
User avatar
Aracknid
Posts: 365
Joined: Tue Aug 10, 2010 3:23 pm
Location: Toronto, Ontario, Canada

How to clear the app storage and cache?

Post by Aracknid » Wed May 22, 2019 4:58 pm

I saw this posting: https://www.ranorex.com/forum/viewtopic ... age#p46196 and I went to the user voice to add my input...

But in the meantime, how do you clear storage or clear cache for your app using adb commands or how can you write code to do it?

Thanks,

Aracknid

PS: Using Ranorex 9.0.1

McTurtle
Posts: 264
Joined: Thu Feb 23, 2017 10:37 am
Location: Benedikt, Slovenia

Re: How to clear the app storage and cache?

Post by McTurtle » Thu May 23, 2019 8:51 am

Hi Aracknid,

You can do this with a "Run application" action by executing the right adb command. For example, for the RxBrowser:
ClearCache.png
ClearCache.png (3.42 KiB) Viewed 334 times
Does it work for you?

Regards,
McTurtle

User avatar
Aracknid
Posts: 365
Joined: Tue Aug 10, 2010 3:23 pm
Location: Toronto, Ontario, Canada

Re: How to clear the app storage and cache?

Post by Aracknid » Thu May 23, 2019 4:03 pm

Thanks McTurtle,

I wrote a code module to do the same thing you suggested. I had seen this solution on the web, but there was conflicting information from people. Some claimed it didn't work for them, others that it was no longer supported or was phone specific. I can say it worked for me with my Android Pixel 2 AVD.

Also, as I'm new to mobile testing and not really clear on it all and how it works... I was trying to avoid ADB if possible, but the more I get into this, the more I realize it's impossible to avoid ADB. Any reasonable testing solution of a mobile app will need to do a bunch of ADB calls to do various things.

I hope Ranorex creates some way to do this easily and documents the many common items people ask about and their solutions. For example, this and dealing with permission popups, copying files from device to local so you can access the data, etc...

I guess I should also mention this is Android specific. I haven't even touched iOS yet.... No idea about that platform yet.

Thanks,

Aracknid.

McTurtle
Posts: 264
Joined: Thu Feb 23, 2017 10:37 am
Location: Benedikt, Slovenia

Re: How to clear the app storage and cache?

Post by McTurtle » Fri May 24, 2019 2:35 pm

Hi Aracknid,

Ranorex also uses ADB :) I guess its just too convenient.
Android is, in my opinion, more flexible than iOS. Courtesy of Apple...

Regards,
McTurtle