I searched like the whole internet but no answer could help me.
I'm trying to get a data string out of an MySQL database but just get this 'andoid.os.NetworkOnMainThreadException'
error. Could anyone help me?
Here is my Code:
public String getInformationForBarcode(String barcode) {
try {
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost("http://www.example.com"); // Yes, i changed this in live code to my url with data in it
ResponseHandler<String> responseHandler = new BasicResponseHandler();
final String response = httpClient.execute(httpPost,
responseHandler);
return response.trim();
} catch (Exception e) {
System.out.println("ERROR : " + e.toString());
return "error";
}
}
Yes, I set the
<uses-permission android:name="android.permission.INTERNET" />
.
All i get is the error message in LogCat :(
Hope one of you can help me!
Thanks for answering.