我已登录使用volley连接到我主机上的php文件的代码 一切都很好但是当我注销并再次登录时,保存的缓存记忆我的旧信息,即使我改变了它。
我尝试使用: requestQueue.getCache()清除()。 stringRequest.setShouldCache(假);没有清除我的缓存
这是我的代码:
private void sendRequest(){
StringRequest stringRequest = new StringRequest(Request.Method.GET,DBConstants.LOG_IN_USER + mEmail + "&password=" + mPassword,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
JSONArray user = null;
JSONObject jsonObject = null;
try {
jsonObject = new JSONObject(response);
user = jsonObject.getJSONArray(JSON_ARRAY);
JSONObject jo = user.getJSONObject(0);
gates = new ArrayList<String>(5);
gateData = new ArrayList<String>();
mEmail = jo.getString(DBConstants.KEY_LOGIN_EMAIL);
mPassword = jo.getString(DBConstants.KEY_LOGIN_PASSWORD);
name = jo.getString(DBConstants.KEY_LOGIN_NAME);
if(!mEmail.equals("null")) {
level = Integer.parseInt(jo.getString(DBConstants.KEY_LOGIN_LEVEL));
for (int i = 1; i < 6; i++) {
gates.add(jo.getString(DBConstants.KEY_LOGIN_GATE + i));
if(!gates.get(i-1).equals("null")) {
for (String dataString : gates.get(i-1).split(";")) {
gateData.add(dataString);
}
newGate = new Gate(gateData.get(0),gateData.get(1),gateData.get(2),
Integer.parseInt(gateData.get(3)),Integer.parseInt(gateData.get(4)),gateData.get(5));
myHandler.addNewGate(newGate);
getAuthorizedList(newGate);
gateData.clear();
}
}
login = true;
} else {
login = false;
}
} catch (JSONException e) {
e.printStackTrace();
}
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
login = false;
}
});
RequestQueue requestQueue = Volley.newRequestQueue(this.getApplicationContext());
requestQueue.getCache().clear();
stringRequest.setShouldCache(false);
requestQueue.add(stringRequest);
}
答案 0 :(得分:0)