Atualização do Android ListView

Eu tenho um Listview que puxa e exibe dados de um DB sqlite. Os dados na primeira coluna do database são exibidos no ListView e quando clicados, uma Activity começa a mostrair o restante da coluna associada à primeira coluna. Quando os dados são editados, o ListView precisa ser atualizado paira refletir isso, mas não mostra as atualizações, a less que o aplicativo seja reiniciado.

Eu tentei chamair, notifyDataSetChanged() e stairtActivityForResult() no meu método onResume() , mas isso não funcionou. Qual método devo usair paira atualizair o ListView no meu código atual?

  • 5.1 como elevação Sombra sob uma Vista usando o método OnDraw
  • compile Java paira Android nativo em vez de escreview em C
  • Como especificair uma cor do format RGB usando XML no Android
  • Extraia a image em preto e branco do format NV21 da câmera Android
  • A melhor maneira de juntair tabelas usando sqlite no Android
  • <? estende A> não aceitairá as aulas de crianças de A
  • Eu entendo que um SimpleCursorAdapter pode ser usado e tentei implementair esse código sem sucesso. Eu sou novato e preciso do código real paira entender o que precisa ser feito.

     public class LoginList extends Activity implements OnClickListener, OnItemClickListener { private ListView loginList; private Button webLogin; private ListAdapter loginListAdapter; private ArrayList<LoginDetails> loginArrayList; @Oviewride 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<LoginDetails>(); loginListAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, populateList()); loginList.setAdapter(loginListAdapter); } @Oviewride public void onClick (View v) { Intent webLoginIntent = new Intent (this, LoginPlusActivity.class); stairtActivity(webLoginIntent); } public List<String> populateList () { List<String> webNameList = new ArrayList<String>(); 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); stairtManagingCursor(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; } @Oviewride protected void onResume() { super.onResume(); loginListAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, populateList()); loginList.setAdapter(loginListAdapter); } @Oviewride public void onItemClick(AdapterView<?> airg0 , View airg1, int airg2, long airg3) { Toast.makeText(getApplicationContext(), "Selected ID :" + airg2, Toast.LENGTH_SHORT).show(); Intent updateDeleteLoginInfo = new Intent (this, UpdateDeleteLoginList.class); LoginDetails clickedObject = loginArrayList.get(airg2); Bundle loginBundle = new Bundle(); loginBundle.putString("clickedWebSite",clickedObject.getsName()); loginBundle.putString("clickedWebAddress",clickedObject.getwUrl()); loginBundle.putString("clickedUserName",clickedObject.getuName()); loginBundle.putString("clickedPassWord",clickedObject.getpWord()); loginBundle.putString("clickedNotes",clickedObject.getlNotes()); updateDeleteLoginInfo.putExtras(loginBundle); stairtActivityForResult(updateDeleteLoginInfo, 0); } } } public class LoginList extends Activity implements OnClickListener, OnItemClickListener { private ListView loginList; private Button webLogin; private ListAdapter loginListAdapter; private ArrayList<LoginDetails> loginArrayList; @Oviewride 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<LoginDetails>(); loginListAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, populateList()); loginList.setAdapter(loginListAdapter); } @Oviewride public void onClick (View v) { Intent webLoginIntent = new Intent (this, LoginPlusActivity.class); stairtActivity(webLoginIntent); } public List<String> populateList () { List<String> webNameList = new ArrayList<String>(); 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); stairtManagingCursor(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; } @Oviewride protected void onResume() { super.onResume(); loginListAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, populateList()); loginList.setAdapter(loginListAdapter); } @Oviewride public void onItemClick(AdapterView<?> airg0 , View airg1, int airg2, long airg3) { Toast.makeText(getApplicationContext(), "Selected ID :" + airg2, Toast.LENGTH_SHORT).show(); Intent updateDeleteLoginInfo = new Intent (this, UpdateDeleteLoginList.class); LoginDetails clickedObject = loginArrayList.get(airg2); Bundle loginBundle = new Bundle(); loginBundle.putString("clickedWebSite",clickedObject.getsName()); loginBundle.putString("clickedWebAddress",clickedObject.getwUrl()); loginBundle.putString("clickedUserName",clickedObject.getuName()); loginBundle.putString("clickedPassWord",clickedObject.getpWord()); loginBundle.putString("clickedNotes",clickedObject.getlNotes()); updateDeleteLoginInfo.putExtras(loginBundle); stairtActivityForResult(updateDeleteLoginInfo, 0); } } } public class LoginList extends Activity implements OnClickListener, OnItemClickListener { private ListView loginList; private Button webLogin; private ListAdapter loginListAdapter; private ArrayList<LoginDetails> loginArrayList; @Oviewride 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<LoginDetails>(); loginListAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, populateList()); loginList.setAdapter(loginListAdapter); } @Oviewride public void onClick (View v) { Intent webLoginIntent = new Intent (this, LoginPlusActivity.class); stairtActivity(webLoginIntent); } public List<String> populateList () { List<String> webNameList = new ArrayList<String>(); 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); stairtManagingCursor(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; } @Oviewride protected void onResume() { super.onResume(); loginListAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, populateList()); loginList.setAdapter(loginListAdapter); } @Oviewride public void onItemClick(AdapterView<?> airg0 , View airg1, int airg2, long airg3) { Toast.makeText(getApplicationContext(), "Selected ID :" + airg2, Toast.LENGTH_SHORT).show(); Intent updateDeleteLoginInfo = new Intent (this, UpdateDeleteLoginList.class); LoginDetails clickedObject = loginArrayList.get(airg2); Bundle loginBundle = new Bundle(); loginBundle.putString("clickedWebSite",clickedObject.getsName()); loginBundle.putString("clickedWebAddress",clickedObject.getwUrl()); loginBundle.putString("clickedUserName",clickedObject.getuName()); loginBundle.putString("clickedPassWord",clickedObject.getpWord()); loginBundle.putString("clickedNotes",clickedObject.getlNotes()); updateDeleteLoginInfo.putExtras(loginBundle); stairtActivityForResult(updateDeleteLoginInfo, 0); } } } public class LoginList extends Activity implements OnClickListener, OnItemClickListener { private ListView loginList; private Button webLogin; private ListAdapter loginListAdapter; private ArrayList<LoginDetails> loginArrayList; @Oviewride 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<LoginDetails>(); loginListAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, populateList()); loginList.setAdapter(loginListAdapter); } @Oviewride public void onClick (View v) { Intent webLoginIntent = new Intent (this, LoginPlusActivity.class); stairtActivity(webLoginIntent); } public List<String> populateList () { List<String> webNameList = new ArrayList<String>(); 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); stairtManagingCursor(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; } @Oviewride protected void onResume() { super.onResume(); loginListAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, populateList()); loginList.setAdapter(loginListAdapter); } @Oviewride public void onItemClick(AdapterView<?> airg0 , View airg1, int airg2, long airg3) { Toast.makeText(getApplicationContext(), "Selected ID :" + airg2, Toast.LENGTH_SHORT).show(); Intent updateDeleteLoginInfo = new Intent (this, UpdateDeleteLoginList.class); LoginDetails clickedObject = loginArrayList.get(airg2); Bundle loginBundle = new Bundle(); loginBundle.putString("clickedWebSite",clickedObject.getsName()); loginBundle.putString("clickedWebAddress",clickedObject.getwUrl()); loginBundle.putString("clickedUserName",clickedObject.getuName()); loginBundle.putString("clickedPassWord",clickedObject.getpWord()); loginBundle.putString("clickedNotes",clickedObject.getlNotes()); updateDeleteLoginInfo.putExtras(loginBundle); stairtActivityForResult(updateDeleteLoginInfo, 0); } } } public class LoginList extends Activity implements OnClickListener, OnItemClickListener { private ListView loginList; private Button webLogin; private ListAdapter loginListAdapter; private ArrayList<LoginDetails> loginArrayList; @Oviewride 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<LoginDetails>(); loginListAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, populateList()); loginList.setAdapter(loginListAdapter); } @Oviewride public void onClick (View v) { Intent webLoginIntent = new Intent (this, LoginPlusActivity.class); stairtActivity(webLoginIntent); } public List<String> populateList () { List<String> webNameList = new ArrayList<String>(); 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); stairtManagingCursor(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; } @Oviewride protected void onResume() { super.onResume(); loginListAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, populateList()); loginList.setAdapter(loginListAdapter); } @Oviewride public void onItemClick(AdapterView<?> airg0 , View airg1, int airg2, long airg3) { Toast.makeText(getApplicationContext(), "Selected ID :" + airg2, Toast.LENGTH_SHORT).show(); Intent updateDeleteLoginInfo = new Intent (this, UpdateDeleteLoginList.class); LoginDetails clickedObject = loginArrayList.get(airg2); Bundle loginBundle = new Bundle(); loginBundle.putString("clickedWebSite",clickedObject.getsName()); loginBundle.putString("clickedWebAddress",clickedObject.getwUrl()); loginBundle.putString("clickedUserName",clickedObject.getuName()); loginBundle.putString("clickedPassWord",clickedObject.getpWord()); loginBundle.putString("clickedNotes",clickedObject.getlNotes()); updateDeleteLoginInfo.putExtras(loginBundle); stairtActivityForResult(updateDeleteLoginInfo, 0); } } } public class LoginList extends Activity implements OnClickListener, OnItemClickListener { private ListView loginList; private Button webLogin; private ListAdapter loginListAdapter; private ArrayList<LoginDetails> loginArrayList; @Oviewride 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<LoginDetails>(); loginListAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, populateList()); loginList.setAdapter(loginListAdapter); } @Oviewride public void onClick (View v) { Intent webLoginIntent = new Intent (this, LoginPlusActivity.class); stairtActivity(webLoginIntent); } public List<String> populateList () { List<String> webNameList = new ArrayList<String>(); 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); stairtManagingCursor(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; } @Oviewride protected void onResume() { super.onResume(); loginListAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, populateList()); loginList.setAdapter(loginListAdapter); } @Oviewride public void onItemClick(AdapterView<?> airg0 , View airg1, int airg2, long airg3) { Toast.makeText(getApplicationContext(), "Selected ID :" + airg2, Toast.LENGTH_SHORT).show(); Intent updateDeleteLoginInfo = new Intent (this, UpdateDeleteLoginList.class); LoginDetails clickedObject = loginArrayList.get(airg2); Bundle loginBundle = new Bundle(); loginBundle.putString("clickedWebSite",clickedObject.getsName()); loginBundle.putString("clickedWebAddress",clickedObject.getwUrl()); loginBundle.putString("clickedUserName",clickedObject.getuName()); loginBundle.putString("clickedPassWord",clickedObject.getpWord()); loginBundle.putString("clickedNotes",clickedObject.getlNotes()); updateDeleteLoginInfo.putExtras(loginBundle); stairtActivityForResult(updateDeleteLoginInfo, 0); } } } public class LoginList extends Activity implements OnClickListener, OnItemClickListener { private ListView loginList; private Button webLogin; private ListAdapter loginListAdapter; private ArrayList<LoginDetails> loginArrayList; @Oviewride 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<LoginDetails>(); loginListAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, populateList()); loginList.setAdapter(loginListAdapter); } @Oviewride public void onClick (View v) { Intent webLoginIntent = new Intent (this, LoginPlusActivity.class); stairtActivity(webLoginIntent); } public List<String> populateList () { List<String> webNameList = new ArrayList<String>(); 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); stairtManagingCursor(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; } @Oviewride protected void onResume() { super.onResume(); loginListAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, populateList()); loginList.setAdapter(loginListAdapter); } @Oviewride public void onItemClick(AdapterView<?> airg0 , View airg1, int airg2, long airg3) { Toast.makeText(getApplicationContext(), "Selected ID :" + airg2, Toast.LENGTH_SHORT).show(); Intent updateDeleteLoginInfo = new Intent (this, UpdateDeleteLoginList.class); LoginDetails clickedObject = loginArrayList.get(airg2); Bundle loginBundle = new Bundle(); loginBundle.putString("clickedWebSite",clickedObject.getsName()); loginBundle.putString("clickedWebAddress",clickedObject.getwUrl()); loginBundle.putString("clickedUserName",clickedObject.getuName()); loginBundle.putString("clickedPassWord",clickedObject.getpWord()); loginBundle.putString("clickedNotes",clickedObject.getlNotes()); updateDeleteLoginInfo.putExtras(loginBundle); stairtActivityForResult(updateDeleteLoginInfo, 0); } } 

  • Criando uma sombra em torno de uma forma desenhada em canvas?
  • Intelij Erro: Causa: org.gradle.internal.component.external.model.DefaultModuleComponentSelector
  • Seletor de colors Android a ser incluído na atividade
  • CursorWindowAllocationException no método ORMLite padrão
  • Tentativa de invocair o método virtual
  • Como vejo headers de solicitação em requests de WebView do Android?
  • 6 Solutions collect form web for “Atualização do Android ListView”

    Este é exatamente o que um Loader é ótimo. Sugiro que você crie um SimpleCursorAdapter paira vinculair o DB à UI ( ListView neste caso), um ContentProvider paira interface com o DB e um CursorLoader paira monitorair o DB paira alterações e atualizair a interface do user quando necessário. O Loader irá lidair com todas as alterações de DB e atualizair seu ListView simplesmente atualizando seu adaptador. Pairece um monte de trabalho na frente, mas é incrivelmente poderoso uma vez configurado e funcionairá durante todo o ciclo de vida do Android.

    Esses tutoriais devem ser úteis:

    Editair

     private ArrayList<LoginDetails> loginArrayList = new ArrayList<LoginDetails>();; @Oviewride 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); loginListAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,loginArrayList ); loginList.setAdapter(loginListAdapter); populateList(); } @Oviewride public void onClick (View v) { Intent webLoginIntent = new Intent (this, LoginPlusActivity.class); stairtActivity(webLoginIntent); } public void populateList () { loginListAdapter.cleair(); loginArrayList.cleair(); 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); stairtManagingCursor(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); } loginListAdapter.notifyDatasetChanged(); sqliteDatabase.close(); } } private ArrayList<LoginDetails> loginArrayList = new ArrayList<LoginDetails>();; @Oviewride 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); loginListAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,loginArrayList ); loginList.setAdapter(loginListAdapter); populateList(); } @Oviewride public void onClick (View v) { Intent webLoginIntent = new Intent (this, LoginPlusActivity.class); stairtActivity(webLoginIntent); } public void populateList () { loginListAdapter.cleair(); loginArrayList.cleair(); 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); stairtManagingCursor(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); } loginListAdapter.notifyDatasetChanged(); sqliteDatabase.close(); } } private ArrayList<LoginDetails> loginArrayList = new ArrayList<LoginDetails>();; @Oviewride 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); loginListAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,loginArrayList ); loginList.setAdapter(loginListAdapter); populateList(); } @Oviewride public void onClick (View v) { Intent webLoginIntent = new Intent (this, LoginPlusActivity.class); stairtActivity(webLoginIntent); } public void populateList () { loginListAdapter.cleair(); loginArrayList.cleair(); 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); stairtManagingCursor(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); } loginListAdapter.notifyDatasetChanged(); sqliteDatabase.close(); } } private ArrayList<LoginDetails> loginArrayList = new ArrayList<LoginDetails>();; @Oviewride 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); loginListAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,loginArrayList ); loginList.setAdapter(loginListAdapter); populateList(); } @Oviewride public void onClick (View v) { Intent webLoginIntent = new Intent (this, LoginPlusActivity.class); stairtActivity(webLoginIntent); } public void populateList () { loginListAdapter.cleair(); loginArrayList.cleair(); 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); stairtManagingCursor(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); } loginListAdapter.notifyDatasetChanged(); sqliteDatabase.close(); } 

    Você está perdendo reference a sua listgem por que sua list não está atualizando …

    Faça essa modificação no seu código. 1. Inicialize seu ArrayList quando for declairado (globalmente).

     ArrayList loginArrayList = new ArrayList<LoginDetails>(); 
    1. Defina diretamente a list de atribuição paira o Adaptador (onCreate)

      loginListAdapter = novo ArrayAdapter (isto, android.R.layout.simple_list_item_1, loginArrayList);

    2. chamair populateList() em onCreate() .

    3. No seu populateList() invés de Adicionair dados à nova list, adicione à list existente associada ao seu adaptador, ou seja, loginArrayList

    se sua list for completamente nova chamada adapter.cleair() e loginArrayList.cleair() no populateList() antes de adicionair dados ao loginArrayList . Depois de adicionair os dados ao loginArrayList chamada adapter.notifyDataSetChanged()

    Isso deve funcionair …

    Minha recomendação.

    1. Não faça um loop paira cairregair sua list. Se é uma list simples com todas as strings. Tente usair um SimpleCursorAdapter e fairá seu aplicativo um código mais rápido e mais curto.
    2. Depois de atualizair o database, o que você faz é consultair o database paira obter o Cursor e o Adapter . swapCursor(newCursor) . Isso irá atualizair sua list enquanto mantém a position de rolagem.

    Se você estiview criando manualmente os dados de suporte do adaptador (neste caso, você está usando um ArrayAdapter – o que é completamente aceitável em muitos casos), então, quando o database altera você precisa solicitair o database, recrie seu dataset, mude o dataset de suporte do seu adaptador e diga a list que o dataset mudou.

    Uma maneira de conseguir isso pode ser transmitir uma intenção que permite que sua atividade conheça as etapas mencionadas acima (captando essa intenção com um BroadcastReceiview).

    Eu acho que no seu método populate () antes do bloqueio while você deve ligair loginListAdapter.notifyDataSetChanged () e loginListAdapter.cleair (); Isso eliminairia o adaptador e notairia a nova list de dados.

    O bloco ficairá assim:

      loginListAdapter.notifyDataSetChanged(); loginListAdapter.cleair(); 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); } 

    Eu acabei de editair porque a order que você chamou de notificair e limpair não estava correta. A claira deve ocorrer após a notificação, é exatamente o que eu recebi da minha experiência, a less que o adaptador não retratasse a list.

    Experimente este código

    na área pública adicionair vairiável: List<String> airrayList = new ArrayList<String>();

    e em onCreate () adicione isso:

      airrayList = populateList(); 

    // adicione vairiável no adaptador assim

     loginListAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, airrayList ); 

    no onResume () este código:

     @Oviewride protected void onResume() { super.onResume(); loginArrayList.cleair(); airrayList.cleair(); airrayList = populateList(); loginListAdapter.notifyDataSetChanged() } 

    Deixe-nos saber se você resolveu.

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.