Androidデバイスを使用して、ローカルエリアネットワーク上のAccessデータベースからデータを取得および設定するアプリを作成しています。サーバー上のphpページと通信するためにHttpPostやHttpGetを使用しており、サーバーはodbcを介してdbと通信します。
うまく機能しますが、各クエリが完了するまでにほぼ1秒かかります。より速い方法はありますか?
実際のデバイスでusbを介してデバッグしています。デバイスのブラウザからphpページにアクセスすると、はるかに高速になります。このネットワークには他のトラフィックはありません。
ありがとう!
編集:データセットを取得するためのコードは次のとおりです。
private JSONArray getData(String phpFile,ArrayList<NameValuePair> nameValuePairs){
String result = "";
InputStream is = null;
JSONArray jArray=null;
try{
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://" + mServerIP + "/dressageNet/"+ phpFile);
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
is = entity.getContent();
}catch(Exception e){
Log.e("log_tag", "Error in http connection "+e.toString());
}
try{
BufferedReader reader = new BufferedReader(new InputStreamReader(is,"iso-8859-1"),8);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");}
is.close();
result=sb.toString();
}catch(Exception e){
Log.e("log_tag", "Error converting result "+e.toString());
}
try{
jArray = new JSONArray(result);
}catch(JSONException e){
Log.e("log_tag", "Error parsing data "+e.toString());
}
nameValuePairs.clear();
return jArray;
}