我正在尝试创建与数据库的连接,并且它在gigerbread 2.3.6中没有问题,而且在高于jellybean os中没有。
这是我的代码 -
new Thread(new Runnable() {
public void run() {
select();
}
}).start();
选择方法 - (我从edittext获取id)
public void select()
{
ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
String id="1";
nameValuePairs.add(new BasicNameValuePair("id",id));
try
{
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://yangoninnovation.com/mmuniteddbphp/conn.php");
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
is = entity.getContent();
txvstartstatus.setText("connected ...");
}
catch(Exception e)
{
txvstartstatus.setText("No Internet connection: ");
}
try
{
BufferedReader reader = new BufferedReader
(new InputStreamReader(is,"iso-8859-1"),8);
StringBuilder sb = new StringBuilder();
while ((line = reader.readLine()) != null)
{
sb.append(line + "\n");
}
is.close();
result = sb.toString();
String re2;
re2=result.substring(result.lastIndexOf(":"));
re2=re2.substring(2, re2.lastIndexOf('"'));
txvstartstatus.setText(re2);
}
catch(Exception e)
{
txvstartstatus.setText("No Internet connection: ");
}
}
我无法控制连接更高版本的Android版本。请帮助我。我的select()在较低版本中成功运行。我该怎么解决呢提前致谢。这个问题让我陷入了大约一个月的困境。希望你可以帮忙!