You’re performing a (potentially slow) network operation on the main thread. If your target SDK is 11 (Honeycomb) or higher this will throw a NetworkOnMainThreadException
on Honeycomb or above, because this behaviour can block the UI and lead to an unresponsive app.
You could use an AsyncTask
to get around this, loading the data in its doInBackground(..)
.
solved Android Connecting with PHP and MySql Force Close [closed]