Can two cursors be compared?

I need to check if two cursors are indicated on the same lines with the same values. Is it possible?

More details:

  • I am loading data from my own ContentProvider
  • I send a request to the server and then update my data inside the ContentProvider with the new values.
  • If the values ​​are changed, I need to notify the user that he can update the data.
+6
source share
2 answers

In SQLite, rows do not have an identifier separate from their column values ​​(but one of these values ​​is ROWID ).

What is required for your data to have some unique columns in the form of a cursor, or a ROWID , or some other key value that does not have duplicates.

Otherwise, you will never know that what you see are just two records that have the same values ​​in these columns.

+3
source

According to CommonsWare's remote answer:

Sort through the corresponding columns in the cursor, extract values ​​and compare them.

Although you cannot know the type of each column in advance, you can find out using Cursor.getType() . You can also use Cursor.getColumnNames() to get the name of each column and the number of columns.

This information will then allow you to use the correct access method to get each value and compare.

+4
source

All Articles