Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get notified when data is changed on a database in android?
    primarykey
    data
    text
    <p>I have this code by how I can get data from a sqllite database and set it to a list view:</p> <pre><code>Cursor cursor = dbAdapter.getAllIncomingData(); if (cursor != null &amp;&amp; cursor.getCount() &gt; 0) { cursor.moveToFirst(); Log.d("ADD/EDIT", cursor.getCount() + ""); int size = cursor.getCount(); incomingDataList = new ArrayList&lt;IncomingData&gt;(size); incomingStringList = new ArrayList&lt;String&gt;(size); for (int i = 0; i &lt; size; i++) { String serial = cursor.getString(cursor .getColumnIndex("serial")); String mapurl = cursor.getString(cursor .getColumnIndex("mapurl")); String datetime = cursor.getString(cursor .getColumnIndex("datetime")); // Device device=new Device(id, label, serial, // contact); Device dev = dbAdapter.getDeviceBySerial(serial); IncomingData inData = new IncomingData(serial, mapurl, datetime); inData.setLabel(dev.getLabel()); inData.setContact(dev.getContact()); incomingDataList.add(inData); cursor.moveToNext(); } inAdapter = new IncomingDataArrayAdapter( MatchpointHistoryActivity.this, R.layout.history_item, incomingDataList); historyList.setAdapter(inAdapter); } </code></pre> <p>the data of the database is being updated by receiving sms, and I have written the insertion query in the receiver class, now I want that if the new data is added or deleted then the cursor will get notified and reset the adapter to the listview, I have to relaunch the activity to view the changes, but I need to notify the changes instant. I dont want to use timer to do this stuff all the time, is there any other way?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload