title: Loading new JSON value using UI thread
body: <p>I am facing problem while updating the new values fetched from json file after some interval (assume any either 5 second or any).I have developed this code and now I am stucked in this. When I run this code it shows the value after second run did not get updated the second time. I have implemented the handler but it is also not working here. I have used UI thread but I am facing problem again while using it.</p>
  
  <pre><code>    public class MainActivity extends AppCompatActivity {
      TextView a,b,c,d,e,f,g,h;
      String result = "";
  
      Handler mHandler = new Handler();
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          a=(TextView) findViewById(R.id.a);
          b=(TextView) findViewById(R.id.b);
          c=(TextView) findViewById(R.id.c);
  
          Runnable hand = new Runnable() {
              @Override
              public void run() {
                  DownloadTask task = new DownloadTask();
                  task.execute("https://api.thingspeak.com/channels/12345/feeds.json?results=1");
              }
          };
  
          new Thread(hand).start();
      }
      public class DownloadTask extends AsyncTask&lt;String, Void, String&gt; {
          @Override
          protected String doInBackground(String... urls) {
              URL url;
              HttpURLConnection urlConnection = null;
  
              try {
                  url = new URL(urls[0]);
                  urlConnection = (HttpURLConnection) url.openConnection();
                  InputStream in = urlConnection.getInputStream();
                  InputStreamReader reader = new InputStreamReader(in);
                  int data = reader.read();
                  while (data != -1) {
  
                      char current = (char) data;
                      result += current;
                      data = reader.read();
                  }
                  return result;
  
              } 
          @Override
           protected void onPostExecute(final String result) {
              super.onPostExecute(result);
              Runnable handa = new Runnable() {
                  @Override
                  public void run() {
                      search(result);
                  }
              };
              new Thread(handa).start();
          }
  
          public void search(String result){
              try {
                  JSONObject jsonObject = new JSONObject(result);
  
                  JSONArray weatherInfo = jsonObject.getJSONArray("feeds");
  
                  JSONObject legsobject = weatherInfo.getJSONObject(0);
                  final String field1 = legsobject.getString("field1");
                  final String field2 = legsobject.getString("field2");
                  final String field3 = legsobject.getString("field3");
                  Thread.sleep(1000);
  
                  mHandler.post(new Runnable() {
                      @Override
                      public void run() {
                          a.setText(field1);
                          b.setText(field2);
                          c.setText(field3);
                      }
                  });
              }
          }
  }
  </code></pre>
  
  <p>Can any one guide because I am beginner in Android and try to do practice. Need your help. Your guidance would help me to learn more.  </p>