简体   繁体   中英

how to get the cache size of installed applications in android

I'm using the following code to get a list of all installed apps on android, my question is how is it possible to get the size of the cache that's used by those applications, any help would be appreciated.

public class CacheActivity extends Activity {

    private ListView lv;
    // private TextView tv;
    private List<PackageInfo> pkNames;

    // private Context context;

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.cache);

        lv = (ListView) findViewById(R.id.cacheList);
        // tv = (TextView) findViewById(R.id.text1);
        pkNames = getPackageManager().getInstalledPackages(0);

        ArrayAdapter<PackageInfo> adapter = new ArrayAdapter<PackageInfo>(this,
                android.R.layout.simple_list_item_1, pkNames);
        lv.setAdapter(adapter);

    }
}

I don't think that's currently possible. As mentioned in that thread there's no public API for that. However there's a little trick that was mentioned here to get the size of an installed application via an hidden function but not directly the cache size. I guess it is a bit normal they want to hide some information about other applications.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM