android


How to display application cache in android


Hi I'm trying to develop an android app that could list all app's along with their cache size, here is my approach, and my code is working fine now.
for(int i=0; i<appCache.size(); i++)
{
try
{
final PackageManager pm = getPackageManager();
Method getPackageSizeInfo;
getPackageSizeInfo = pm.getClass().getMethod("getPackageSizeInfo", String.class, IPackageStatsObserver.class);
getPackageSizeInfo.invoke(pm, appPackageName.get(i), new IPackageStatsObserver.Stub() {
#Override
public void onGetStatsCompleted(PackageStats pStats, boolean succeeded)
throws RemoteException
{
final String title;
ApplicationInfo applicationInfo;
try {
applicationInfo = pm.getApplicationInfo(pStats.packageName, 0);
title = (String)((applicationInfo != null) ? packageManager.getApplicationLabel(applicationInfo) : "???");
MessageDetails Detail;
Detail = new MessageDetails();
Detail.setIcon(getPackageManager().getApplicationIcon( pStats.packageName ));
Detail.setName(title);
Detail.setSub("Cache Size -> "+(pStats.cacheSize/1024));
details.add(Detail);
}
catch (final NameNotFoundException e) {}
}
});
}
catch (SecurityException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
}catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
But here all app's installed in device gets listed along with their cache, but I want to filter the list to those app's whose cache size is greater than 0, please help me to solve this riddle, Thank you.

Related Links

Can I show more info in Settings > Apps > App Info on Android?
Why cold swap is affected by API level while hot swap isn't in Android Instant Run?
Check if a realmObject has been updated
Displaying suggestions for Searchview inside a Dialog
Plot marker on map from autocomplete item clicked
getLastKnownLocation() returning null and app not showing under “Recent Location Requests” on emulator
android fragment using activity
RecyclerView inside NestedScrollView, load Imageview
ANDROID_HOME is not set (Ubuntu 16.04)
HTML5 video controls disappear in full-screen mode on android devices
Android Popup window from edittext keep focus
How to Pass the Data from Listview A to ListView B?
getDownloadURL and post to Firebase Database on Android sometimes doesn't work
Is it possible to run OAT/ELF files from command line on Android?
QTextDocument line spacing too big
Cancel alarm set by SetAlarmClock

Categories

HOME
algorithm
grok
cheerio
dns
fftw
sitecore
jsf-2.2
spring-data-redis
newrelic
google-apps
permissions
zip
nuget-package
retrofit2
mql5
pega
activecollab
filechannel
nancy
shared-libraries
flatpak
do-while
package-managers
entitymanager
red5
android-7.0-nougat
sse
nodemcu
asciidoctor-pdf
ksh
angular-routing
dynamically-generated
strongname
underscore.js
intersystems-cache
paperjs
postback
kudu
cart
r-grid
openerp-7
sim-toolkit
docfx
google-earth-engine
ideascript
z-notation
bc
recurrent-neural-network
ogc
xv6
escpos
plr
smoothstate.js
placeholder
automapper-5
spring-integration-sftp
insight
posixct
zenhub
monkey
restore
omxplayer
autosar
actor-platform
mapinfo
swizzling
kango-framework
grass
computer-architecture
include-guards
cgi-bin
sql-server-data-tools
dnssec
nutiteq
aspectj-maven-plugin
matlab-deployment
boost-program-options
tweenlite
tinyxml
multiautocompletetextview
gwt-openlayers
ora-06550
nevron
css-reset
android-icons
composite-component
fb.ui
extreme-programming
qi4j
faye
paginator
extconf.rb
cgimage
apache-commons-dbutils
cgbitmapcontextcreate
dataform
load-time
vs-android
ajax-polling
lxr
interop-domino
complex-event-processing
asynchronous-wcf-call
java1.4

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App