title: Android ListView sqlite update Refresh
body: <p>My current application has a Listview which pulls and displays data from a sqlite DB. Data in the first column of the DB is displayed in the listview and when clicked, an activity starts showing the rest of the column associated with the first column. When the data is edited, the DB updates but the listview does not show the updates unless the application is restarted. I am trying to implement startActivityForResult() in my onResume method but am unsuccessful. I am trying to refresh my listview after the DB has been updated. How can I accomplish this. </p>
  
  <p>ListView Activity:</p>
  
  <pre><code>@Override 
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.login_listview);
  
  
      loginList = (ListView)
     findViewById(R.id.loginlist);
      loginList.setOnItemClickListener(this);
  
      webLogin = (Button)
     findViewById(R.id.button3);
      webLogin.setOnClickListener(this);
  
      loginArrayList = new ArrayList&lt;LoginDetails&gt;();
  
      loginListAdapter = new ArrayAdapter&lt;String&gt;(this,   android.R.layout.simple_list_item_1, populateList());
      loginList.setAdapter(loginListAdapter);
  }
  
  @Override
  public void onClick (View v) {
      Intent webLoginIntent = new Intent (this, LoginPlusActivity.class);
      startActivity(webLoginIntent);
  }
  
  public List&lt;String&gt; populateList (){
  
      List&lt;String&gt; webNameList = new ArrayList&lt;String&gt;();
  
      dataStore openHelperClass = new dataStore (this);
  
      SQLiteDatabase sqliteDatabase = openHelperClass.getReadableDatabase();
  
      Cursor cursor = sqliteDatabase.query(dataStore.TABLE_NAME_INFOTABLE, null, null, null, null, null, dataStore.COLUMN_NAME_SITE, null);
  
      startManagingCursor(cursor);
  
      while (cursor.moveToNext()){
  
      String sName = cursor.getString(cursor.getColumnIndex(dataStore.COLUMN_NAME_SITE));
      String wUrl = cursor.getString(cursor.getColumnIndex(dataStore.COLUMN_NAME_ADDRESS));
      String uName = cursor.getString(cursor.getColumnIndex(dataStore.COLUMN_NAME_USERNAME));
      String pWord = cursor.getString(cursor.getColumnIndex(dataStore.COLUMN_NAME_PASSWORD));
      String lNotes = cursor.getString(cursor.getColumnIndex(dataStore.COLUMN_NAME_NOTES));
  
      LoginDetails lpDetails = new LoginDetails();
  
          lpDetails.setsName(sName);
          lpDetails.setwUrl(wUrl);
          lpDetails.setuName(uName);
          lpDetails.setpWord(pWord);
          lpDetails.setlNotes(lNotes);
  
          loginArrayList.add(lpDetails);
          webNameList.add(sName);
  }
  
  sqliteDatabase.close();
  return webNameList;
  }
  
  
  
  @Override
  protected void onResume() {
      super.onResume();
  
      Intent i = new Intent(LoginList.this, UpdateDeleteLoginList.class);
      LoginList.this.startActivityForResult(i, 1);    
      loginList.setAdapter(loginListAdapter);
  
  loginListAdapter = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_list_item_1, populateList());
  loginList.setAdapter(loginListAdapter);
  
  }
  </code></pre>
  
  <p>update Activity:</p>
  
  <pre><code>     @Override
  public void onClick(View v){
  
      loginSitetext = sName.getText().toString();
      loginAddresstext = wUrl.getText().toString();
      loginUsertext = uName.getText().toString();
      loginpassWordtext = pWord.getText().toString();
      loginNotestext = lNotes.getText().toString();
  
      LoginDetails loginDetails = new LoginDetails();
  
      loginDetails.setsName(bundledWebSite);
      loginDetails.setwUrl(bundledWebAddress);
      loginDetails.setuName(bundledUserName);
      loginDetails.setpWord(bundledPassWord);
      loginDetails.setlNotes(bundledNotes);
  
      if(v.getId()==R.id.rucBttn){
          finish();
  
      }else if(v.getId()==R.id.ruuBttn){
          updateLoginDetails(loginDetails);
  
          Intent returnIntent = new Intent();
          setResult(RESULT_CANCELED, returnIntent);
          finish();
  
      }else if(v.getId()==R.id.rudBttn){
          deleteLoginDetails(loginDetails);
      }
  
  }
  
  
  private void updateLoginDetails(LoginDetails loginDetails){
  
      dataStore androidOpenDbHelper = new dataStore(this);
  
      SQLiteDatabase sqliteDatabase = androidOpenDbHelper.getWritableDatabase();
  
      ContentValues contentValues = new ContentValues();
  
      contentValues.put(dataStore.COLUMN_NAME_SITE, loginSitetext);
      contentValues.put(dataStore.COLUMN_NAME_ADDRESS, loginAddresstext);
      contentValues.put(dataStore.COLUMN_NAME_USERNAME, loginUsertext);
      contentValues.put(dataStore.COLUMN_NAME_PASSWORD, loginpassWordtext);
      contentValues.put(dataStore.COLUMN_NAME_NOTES, loginNotestext);
  
      String[] whereClauseArgument = new String[1];
      whereClauseArgument[0] = loginDetails.getsName();
  
      System.out.println("whereClauseArgument[0] is :" + whereClauseArgument[0]);
  
      sqliteDatabase.update(dataStore.TABLE_NAME_INFOTABLE, contentValues, dataStore.COLUMN_NAME_SITE+"=?", whereClauseArgument);
  
      sqliteDatabase.close();
      finish();
  </code></pre>