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

How to make Modal to show up as a different Component in react-native
How to sort a list of points nearest to a given point (latitude and longitude)?
Gradle sync failed error in android studio
React Native v0.42 flexbox error in ScrollView
Android Emulator not working on ubuntu 14.04 LTS
AbstractAccountAuthenticator prompt login in refresh token when stored credential are no longer valid
Using ZXing Mobile in Xamarin Forms app
Progressive web app Google play [closed]
Android: Create and Download PDF files to Downloads directory
Android Firebase how to retrieve one record by ID?
How to find mfcc in android
How to show multiple images inside Linear Layout?
Prevent users from disabling Google ads in android application
Android - share the app link to Facebook
errors in failed to resolve in intellij idea 2017.1.2
ArrayListAdapter - ListView animations

Categories

HOME
paraview
developer-tools
polymer
battery
sh
can
pyqt4
jetty
modal-dialog
bing-maps
accessibility
filechannel
supervisor
plink
http-post
android-7.0-nougat
forgot-password
topology
microsoft-ocr
imagemap
direct3d11
comparator
beautifier
delimiter
apktool
alm
dst
login-script
keras-layer
carriage-return
indy10
latitude-longitude
alphabetical
google-earth-engine
reactivekit
cin
p4merge
claims
apollostack
avcapturedevice
servermanager
openresty
spring-integration-sftp
fclose
custom-font
yii2-user
mouseleave
flyout
mathcad
django-1.10
stripe-connect
atlas
model-associations
avspeechsynthesizer
google-query-language
omniauth-facebook
grass
concept-insights
google-books
sapscript
sql-server-data-tools
botan
telepat
teamcity-9.1
grouping-sets
mass-assignment
execve
webmatrix-3
packet-sniffers
ghcjs
appserver
entry-point
linkedin-jsapi
angular-carousel
ss7
grails-domain-class
wxformbuilder
gnumeric
maven-scm
decoupling
ebay-lms
joomla-template
onload-event
redis-py
midlet
nokia-s40
zope.interface
objectquery
wiimote
denied
tmx
strtod
glui
unmanagedresources
httpcookie
xslcompiledtransform
appliance
great-circle

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