i am using HttpURLConnection
and i want to create async application. for example if data changed into mysql database the auto update into application.
i read about handler but i cant understand how can i use in my case.
here is my code for getting data from database using api
private class GetGroupsMember extends AsyncTask<String, Void, String> {
@Override
protected String doInBackground(String... params) {
String response = null;
try {
URL url = new URL(params[0]);
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
InputStream inputStream = urlConnection.getInputStream();
urlConnection.connect();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
response = bufferedReader.readLine();
bufferedReader.close();
urlConnection.disconnect();
return response;
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(String response){
super.onPostExecute(response);
Log.d("response",response);
}
}