0

In an Android application, I got a query response from the database and I created a cursor object for it (for example, a contact list).

I want to delete some rows of this database response and create a new cursor that matches the database answer but there are no extra rows.

In fact, I want to add some code like a proxy in the application, which means that it gets the query answers, Edit it and then get it to to the new cursor object. Can you guide me? What should I do?

Cursor cursor = cr.query(ContactsContract.Contacts.CONTENT_URI, null, null, null, ContactsContract.Contacts.DISPLAY_NAME + " LIMIT 5");
    // remove some results 
    Cursor newCursor= answers with new results
Happy Developer
  • 617
  • 1
  • 8
  • 15
  • Is there a reason you can't just use the selection+selectionArgs parameters of the query method to filter out the ones you don't want? – Matt May 21 '19 at 11:29
  • Yes, because the rows that are to be removed are specific rows with complex analyzes that depends on their data. they cant be described in this way. @Matt – Happy Developer May 22 '19 at 07:54
  • Fair enough. Just out of curiosity could you give an example? I would suggest reading the initial results into a temporary db table and then just query that table for everything in it to get back to a Cursor. – Matt May 23 '19 at 09:30
  • good idea. thanks. i want to repackage the application and remove the access of application to specific contacts , which means, after query, show the dialogbox to contact to select which one of them should not take to the application. and then create the cursor again for app, to continue its job. @Matt – Happy Developer May 23 '19 at 11:11
  • The best answer for my question is on this link: [https://stackoverflow.com/questions/3766688/filtering-a-cursor-the-right-way](https://stackoverflow.com/questions/3766688/filtering-a-cursor-the-right-way) – Happy Developer May 27 '19 at 10:17

0 Answers0