Java setShouldCache(false)不工作
我有一个登录代码,它使用截击连接到我主机上的php文件 一切都很好,但当我注销并再次登录时,保存的缓存会记住我的旧信息,即使我更改了它 我尝试使用: requestQueue.getCache().clear(); stringRequest.setShouldCache(false) 不清除我的缓存 这是我的代码:Java setShouldCache(false)不工作,java,android,android-volley,Java,Android,Android Volley,我有一个登录代码,它使用截击连接到我主机上的php文件 一切都很好,但当我注销并再次登录时,保存的缓存会记住我的旧信息,即使我更改了它 我尝试使用: requestQueue.getCache().clear(); stringRequest.setShouldCache(false) 不清除我的缓存 这是我的代码: private void sendRequest(){ StringRequest stringRequest = new StringRequest(Request.Me
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);
}
private void sendRequest(){
StringRequest StringRequest=new StringRequest(Request.Method.GET,DBConstants.LOG_IN_USER+mEmail+“&password=“+mPassword,
新的Response.Listener(){
@凌驾
公共void onResponse(字符串响应){
JSONArray user=null;
JSONObject JSONObject=null;
试一试{
jsonObject=新的jsonObject(响应);
user=jsonObject.getJSONArray(JSON_数组);
JSONObject jo=user.getJSONObject(0);
门=新阵列列表(5);
gateData=newarraylist();
mEmail=jo.getString(DBConstants.KEY\u LOGIN\u EMAIL);
mPassword=jo.getString(DBConstants.KEY\u LOGIN\u PASSWORD);
name=jo.getString(DBConstants.KEY\u LOGIN\u name);
如果(!mEmail.equals(“null”)){
level=Integer.parseInt(jo.getString(DBConstants.KEY\u LOGIN\u level));
对于(int i=1;i<6;i++){
add(jo.getString(DBConstants.KEY_LOGIN_GATE+i));
如果(!gates.get(i-1).equals(“null”)){
for(stringdatastring:gates.get(i-1.split)(;)){
gateData.add(dataString);
}
newGate=newGate(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);
获取授权列表(newGate);
gateData.clear();
}
}
login=true;
}否则{
登录=假;
}
}捕获(JSONException e){
e、 printStackTrace();
}
}
},
新的Response.ErrorListener(){
@凌驾
公共无效onErrorResponse(截击错误){
登录=假;
}
});
RequestQueue RequestQueue=Volley.newRequestQueue(this.getApplicationContext());
requestQueue.getCache().clear();
stringRequest.setShouldCache(false);
添加(stringRequest);
}
很抱歉,您可以关闭
在我的托管帐户上,我有缓存管理器,我关闭了它,它工作得很好