Android - Can you update a Cursor for SQLite results?

后端 未结 3 1204
生来不讨喜
生来不讨喜 2020-12-20 15:57

One of my methods returns a Cursor from some SQLite query results.

As I\'m navigating through the cursor, there are some records I want to change/update. Can I updat

相关标签:
3条回答
  • 2020-12-20 16:22

    You need to implement a Content Provider that allows to update the record, in short you need to override the update function in your ContentProvider class.

    public int update(Uri uri, ContentValues values, String where, String[] whereArgs)
    

    In short you'll have to update them, this is not done directly from the data received in the Cursor.

    This and this link should help.

    0 讨论(0)
  • 2020-12-20 16:35

    To do that the best way is to implement a content provider for your data http://developer.android.com/guide/topics/providers/content-providers.html

    You can use framework like datadroid for that http://datadroid.foxykeep.com/

    0 讨论(0)
  • 2020-12-20 16:39

    You can not directly update records with the cursor. Read the Android Cursor doc.

    0 讨论(0)
提交回复
热议问题