【问题标题】:Clear Android Gallery Cache清除 Android 图库缓存
【发布时间】:2020-06-10 05:23:29
【问题描述】:

我使用此代码清除已安装应用程序的缓存数据,它在有根设备上完美运行:

PackageManager  pm = getPackageManager();
    // Get all methods on the PackageManager
    Method[] methods = pm.getClass().getDeclaredMethods();
    for (Method m : methods) {
        if (m.getName().equals("freeStorage")) {
            // Found the method I want to use
            try {
                long desiredFreeStorage = 8 * 1024; // Request for 8GB of free space
                m.invoke(pm, desiredFreeStorage , null);
                Toast.makeText(this, "Cache Cleared!", Toast.LENGTH_LONG).show();
            } catch (Exception e) {
                txtView.setText(e.getMessage());
            }
            break;
        }
    }

但此代码仅适用于已安装的应用程序,不适用于系统安装的应用程序(例如画廊),我想以编程方式清除画廊应用程序的缓存,例如以下操作: Clear Gallery Cache

【问题讨论】:

标签: java android caching gallery


【解决方案1】:

这在非 root 设备上是不可能的,因为 Android 不允许它,因为 Marshmallow, 请通过this ans了解更多详细信息, https://stackoverflow.com/a/17334600/4032259

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-18
    • 1970-01-01
    • 1970-01-01
    • 2011-10-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多