我没有任何正确的代码将数据发送到StorageFile
中的外部数据库,因为API level 23
方法已被弃用。请帮我。我很久以前就被困在这里了。
答案 0 :(得分:0)
您可以使用StringRequest
,例如:
public static JSONObject sendRequestGetReserves(RequestQueue requestQueue)
throws InterruptedException, ExecutionException, TimeoutException, JSONException {
JSONObject response = null;
RequestFuture<String> requestFuture = RequestFuture.newFuture();
StringRequest strRequest = new StringRequest(Request.Method.POST,
"Your url", requestFuture, requestFuture) {
@Override
protected Map<String, String> getParams() {
Map<String, String> params = new HashMap<>();
params.put("Your NameValuePair1", "value1");
params.put("Your NameValuePair2", "value2");
return params;
}
};
requestQueue.add(strRequest);
response = new JSONObject(requestFuture.get(30000, TimeUnit.MILLISECONDS));
return response;
}