I am using WebService to Get Data, but I only get 9 records of 62, I think this is problem of Buffer size, am I Right?
I use following code to get Data from WebService, and Webserivce is developed in php.
public JSONObject PostConnectionObject(String strUrl,ArrayList<NameValuePair> alstNameValuePair) {
InputStream mInputStream = null;
try {
//This is the default apacheconnection.
HttpClient mHttpClient = new DefaultHttpClient();
//Pathe of serverside
HttpPost mHttpPost = new HttpPost(strUrl);
if(alstNameValuePair!=null)
{
//post the valur you want to pass.
mHttpPost.setEntity(new UrlEncodedFormEntity(alstNameValuePair));
}
//get the valu from the saerverside as response.
HttpResponse mHttpResponse = mHttpClient.execute(mHttpPost);
HttpEntity mHttpEntity = mHttpResponse.getEntity();
mInputStream = mHttpEntity.getContent();
}
catch (Exception e) {
// TODO Auto-generated catch block
Log.e(strTAG,"Error in HttpClient,HttpPost,HttpResponse,HttpEntity");
}
String strLine = null;
String strResult = null;
//convert response in to the string.
try {
BufferedReader mBufferedReader = new BufferedReader(new InputStreamReader(mInputStream,"iso-8859-1"), 8);
StringBuilder mStringBuilder = new StringBuilder();
while((strLine = mBufferedReader.readLine()) != null) {
mStringBuilder.append(strLine + "\n");
}
mInputStream.close();
strResult = mStringBuilder.toString();
System.out.println("Value of Result :"+strResult);
}
catch (Exception e) {
// TODO Auto-generated catch block
//System.out.println("Error in BufferedReadering");
Log.e(strTAG,"Error in BufferedReadering");
}
The documentation for InputStreamReader does not provide a way to set the size of the buffer it uses. The size of the buffer is up to the implementor.
In your code you use a buffer size of 8 for the BufferedReader(). So you could change the size of the BufferedReader's buffer by changing the 8 (second param of BufferedReader()).
I do not think that will help though. BufferedReader still returns entire lines even when its buffer size is much smaller than the length of the lines.
Your code looks straight forward and I suspect that the data is never being sent.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With