How to update a ListView if the database value changes?

I am currently doing the following:

1) the database is associated with a ListView:

String[] from = new String[]{DbAdapter.KEY_TITLE, 
                DbAdapter.KEY_DISPLAYED_VALUE,
                DbAdapter.KEY_FAVORITE};
int[] to = new int[]{R.id.name, R.id.time, R.id.icon};
items = new SimpleCursorAdapter(this, R.layout.row, itemsCursor, from, to);

2) KEY_DISPLAYED_VALUEchanges every 2 seconds in the database. Then called items.notifyDataSetChanged(). But the data on the screen is not updated ( R.id.timeis TextViewcurrently going to be TextSwitcherafter this code).

The database is updated by execSQL .

+3
source share
2 answers

This explains how to use notifyDataSetChanged (), and why your example does not work:

notifyDataSetChanged example

+2
source

, . - , - (, - ). - uri (. android , .

, ( ), , , , , 2 , , ui . ( , - 5 ).

, , .

+3

All Articles