[General Questions and Answers] GalaxyA325G:
Someone (elsewhere) recently asked me this question:

And my answer was the following - but which I'd like to flesh out with a better answer as I've never done it.

What would you write to improve the answer below that I gave that person?

I suggested he first might want to use a benchmark tool to see how well his phone supports background processing such as this open source cache test.

<https://play.google.com/store/apps/details?id=com.urbandroid.dontkillmyapp>

And then I suggested he might want to use a dedicated cache cleaner tool such as this.

<https://play.google.com/store/apps/details?id=com.github.bmx666.appcachecleaner.googleplay>

<https://play.google.com/store/apps/details?id=com.mitigator.gator>

<https://play.google.com/store/apps/details?id=com.symantec.cleansweep>

Other well rated cache cleaner apps which contain ads are these.

<https://play.google.com/store/apps/details?id=com.redsoft.zerocleaner>

<https://play.google.com/store/apps/details?id=com.a0soft.gphone.acc.free>

<https://play.google.com/store/apps/details?id=com.baloota.xcleaner>

And, of course, the adb pm trim-caches command takes the desired free space parameter in kilo/mega/gigabytes to trim to.

C:\> adb shell pm trim-caches 64K

C:\> adb shell pm trim-caches 64M

C:\> adb shell pm trim-caches 64G

He can also specify an impossibly large amount of free space to seek,

which effectively will trim the cache for all non-running apps.

C:\> adb shell pm trim-caches 9999999999

Or, he can specify that adb clear the App Data & Cache of an app.

ADB Command for clearing App Data and Cache

C:\> adb shell pm clear my.package.name

Or he can limit the clearing to only the Cache & not to App Data.

C:\> adb shell pm clear --cache-only my.package.name

Since ADB can run a Linux command on the phone, this Linux command will clear all data along with cache for all the apps on the phone.

C:\> adb shell cmd package list packages | cut -d":" -f2 | while read package;do pm clear $package:done

Of course, if he's rooted, he can use the su commands to do it.

C:\> adb shell

su -c "rm -r /data/dalvik-cache"

C:\> adb shell

su -c "rm -r /cache/dalvik-cache"

Or for one package alone, if he's rooted, he can use this.

C:\> adb shell

su -c "rm -rf /data/data/my.package.name/cache/*"

There are other more drastic ways to clear the data and cache

but I wouldn't recommend them since it's not usually needed.

a. Fastboot

b. TWRP Recovery

Fastboot is a protocol used for diagnosing Android devices and flashing firmware images onto them using USB. The Fastboot Mode isn't available for Samsung users as Galaxy devices use the Download Mode instead.

Using Fastboot Commands, he'll be able to erase partitions like cache and user data on your Android smartphone.

1. Connect your smartphone to a PC and launch a command window

Win+R cmd [Control+Shift+Enter]

2. adb reboot bootloader

3. Wait until your smartphone enters the Fastboot Mode

In a separate PowerShell or Terminal window, enter this:

fastboot erase cache

4. Once the cache partition is wiped, reboot.

fastboot reboot

He can also wipe the system cache using the stock recovery or TWRP.

1. Boot your smartphone into Recovery Mode using hardware keys,

ADB commands, or tools like ADB AppControl/WebADB

2. Connect your smartphone to your PC & in a terminal type

adb reboot recovery

3. Wait until your smartphone reboots into the Recovery Mode

4. Highlight the Wipe Cache Partition option & then press the Power key

5. Select the YES option to confirm system cache deletion

6. Once the cache partition is wiped, you should return to the home

screen in recovery and then select 'Reboot System Now'

If you are using TWRP Recovery, you need to select

Wipe > Advanced App > Dalvik/ART Cache

and then Swipe to wipe to delete the system cache.

I'm not aware of a release option as some had suggested.

adb shell pm trim-caches <release>

But it might exist for all I know as I have never done this myself.

Speaking of writing from memory, I'm told SD Maid will supposedly clear the cache for all your apps whether or not you are rooted.

<https://play.google.com/store/apps/details?id=eu.thedarken.sdm>

SD Maid works unrooted but has more capability on rooted devices.

<https://github.com/d4rken-org/sdmai...ed-Questions#does-sd-maid-only-work-with-root>

In rooted devices, SD Maid clears all the app caches & uses less RAM.

In unrooted devices, SD Maid goes to the app info for each app

to clear the cache (and needs accessibility permissions which uses RAM).

Unrooted may also need a "force stop app" to stop apps to clear cache.

<https://play.google.com/store/search?q=force stop apps&c=apps>

For example these are the first three in that force-stop-app search:

<https://play.google.com/store/apps/details?id=com.force.stop.apps>

<https://play.google.com/store/apps/details?id=com.tafayor.killall>

<https://play.google.com/store/apps/details?id=com.redsoft.appkiller>

But these app killers (which force stop background apps) have no ads.

<https://play.google.com/store/apps/details?id=org.codedrink.app_killer>

<https://play.google.com/store/apps/details?id=me.piebridge.brevent>

<https://play.google.com/store/apps/details?id=com.app.detail>

Be advised I haven't tried any of these so I'm just letting people know what I remember, offhand, was the answer every time that same question was asked.

Is there a better answer to provide to the person who had asked?