一度に複数のJson文字列[各1MB]をPHPサーバーに送信しようとしています。10レコードを送信しようとすると、正常に機能します。ただし、20レコードを超える場合は、と表示されますOutOfMemoryException
。私はAndroidのメモリサイズ制限t015MB-16MBを見ました。しかし、これを解決する方法の手がかりはありません。私は以下のコードを使用して、一度に複数のレコードを送信しています。
/** Upload Data*/
private void submitUploadData(String url, Map<String, String> param)
throws IOException {
URL siteUrl;
try {
siteUrl = new URL(url);
HttpURLConnection conn = (HttpURLConnection) siteUrl
.openConnection();
conn.setRequestMethod("POST");
conn.setDoOutput(true);
conn.setDoInput(true);
DataOutputStream out = new DataOutputStream(conn.getOutputStream());
String content1 = "";
Set getkey = param.keySet();
Iterator keyIter = getkey.iterator();
String content = "";
for (int i = 0; keyIter.hasNext(); i++) {
Object key = keyIter.next();
if (i != 0) {
content += "&"; //Crashing here
}
content += key + "=" + param.get(key); //Crashing here
System.out.println("Content" + content);
}
System.out.println(content);
out.writeBytes(content.trim());
out.flush();
out.close();
BufferedReader in = new BufferedReader(new InputStreamReader(
conn.getInputStream()));
String jsonresponse = "";
while ((jsonresponse = in.readLine()) != null) {
System.out.println(jsonresponse);
if(!jsonresponse.equals("Authorisation Successful")){
updateUploadRecords(jsonresponse);}
}
in.close();
} catch (MalformedURLException e) {
e.printStackTrace();
}
}