I have an update fragment using which i will update data in my database. Once the update is done i move back to 'view the data from database' fragment and i need the list to be updated. I think i have to write code for this inside onResume() but i don't know how to do it. Code for 'view the data from database' fragment:
public class Testing extends Fragment {
String uname="921312104053";
private static final String TAG_RESULTS="result";
private static final String TAG_Sname = "Subject_name";
private static final String TAG_Scode = "Subject_code";
private static final String TAG_Sgrade ="Grade";
ListView lv;
JSONArray subjects = null;
String myJSON;
ListAdapter adapter;
ArrayList<HashMap<String, String>> subList,subList1;
public Testing() {
}
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_testing,
            container, false);
    disp(view);
    return view;
}
public void disp(View view)
{
    lv = (ListView)view.findViewById(R.id.list);
    subList = new ArrayList<HashMap<String,String>>();
    getData(view);
}
public void getData(View view){
    class GetDataJSON extends AsyncTask<String, Void, String> {
        @Override
        protected String doInBackground(String... params) {
            DefaultHttpClient httpclient = new DefaultHttpClient(new BasicHttpParams());
            HttpPost httppost = new HttpPost("http://10.0.2.2/markolepsy/android_connect/testing.php?usrname="+uname);
            httppost.setHeader("Content-type", "application/json");
            InputStream inputStream = null;
            String result = null;
            try {
                HttpResponse response = httpclient.execute(httppost);
                HttpEntity entity = response.getEntity();
                inputStream = entity.getContent();
                BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"), 8);
                StringBuilder sb = new StringBuilder();
                String line = null;
                while ((line = reader.readLine()) != null)
                {
                    sb.append(line + "\n");
                }
                result = sb.toString();
            } catch (Exception e) {
            }
            finally {
                try{if(inputStream != null)inputStream.close();}catch(Exception squish){}
            }
            return result;
        }
        @Override
        protected void onPostExecute(String result){
            myJSON=result;
            showList();
        }
    }
    GetDataJSON g = new GetDataJSON();
    g.execute();
}
protected void showList(){
    try {
        JSONObject jsonObj = new JSONObject(myJSON);
        subjects = jsonObj.getJSONArray(TAG_RESULTS);
        for(int i=0;i<subjects.length();i++){
            JSONObject c = subjects.getJSONObject(i);
            String sname = c.getString(TAG_Sname);
            String scode = c.getString(TAG_Scode);
            String sgrade = c.getString(TAG_Sgrade);
            HashMap<String,String> records = new HashMap<String,String>();
            records.put(TAG_Sname,sname);
            records.put(TAG_Scode,scode);
            records.put(TAG_Sgrade,sgrade);
            subList.add(records);
        }
        adapter = new SimpleAdapter(
                getActivity(), subList, R.layout.list_layout,
                new String[]{TAG_Sname,TAG_Scode,TAG_Sgrade},
                new int[]{R.id.subject_name, R.id.subject_code, R.id.grade}
        );
        lv.setAdapter(adapter);
    } catch (JSONException e) {
        e.printStackTrace();
    }
}
}
 
     
     
    