Android:Volley不删除缓存

时间:2014-09-21 12:08:34

标签: android caching android-volley

我已添加凌空以获取获取Json对象和缓存数据的请求。但是当我清除所有缓存时,似乎所有数据都没有删除。 因为当我关闭我的网络并重新启动我的应用程序时。它仍然使用缓存。

我执行以下代码

public class AppController扩展了Application {

public static final String TAG = AppController.class.getName();

public static AppController mIntance;

private RequestQueue requestQueue;

private ImageLoader imageLoader;

/**
 * onCreate of class that is extend Application always call first when app laucher . to benefit 
 * create object singleton. 
 * 
 * @param err
 * @param context
 * @return
 */
@Override
public void onCreate() {
    super.onCreate();
    mIntance = this;


}


public static synchronized AppController getIntance() {

    return mIntance;
}

public RequestQueue getRequestQueue() {

    /*
     * if (requestQueue == null) { requestQueue =
     * MyRequest.newRequestQueue(getApplicationContext()); }
     */

    if (requestQueue == null) {
        requestQueue = Volley.newRequestQueue(getApplicationContext());
    }

    return requestQueue;
}


public <T> void addToRequestQueue(Request<T> req, String tag) {

    // hoa ra settag la cho req nay ,. minh cu tuong no set cho c�i
    // requestqueue

    req.setTag(tag.equals("") ? TAG : tag);
    getRequestQueue().add(req);

}

// using request with string default
public <T> void addToRequestQueue(Request<T> req) {
    req.setTag(TAG);
    getRequestQueue().add(req);
}


public void cancelRequest(Object tag) {
    if (requestQueue != null) {
        requestQueue.cancelAll(tag);

    }

}

public void cancelAllRequest() {
    if (requestQueue != null) {
        requestQueue.cancelAll("feed_request");

    }

}

/*
 * clear some cache
 */

public void DeletelCacheFromSomeURL(ArrayList<String> array) {
    for (int i = 0; i < array.size(); i++) {
        requestQueue.getCache().remove(array.get(i));
    }

}

}

我已清除所有缓存流量

AppController.getIntance().getRequestQueue().getCache()
                        .clear();

任何人解释并给我解决方案。谢谢!

0 个答案:

没有答案