search

Home  >  Q&A  >  body text

Android ContentProvider用法解惑

PHPzPHPz2773 days ago712

reply all(3)I'll reply

  • 巴扎黑

    巴扎黑2017-04-17 17:05:14

    Sorry, I’m asking myself again. I have solved this problem at the code level, and the solution is:

    1. If the update, insert, and delete of ContentProvider will affect the display of the UI, then the DB cannot be directly manipulated in the code. Instead, ContentProvider should be used uniformly, and ContentObserver needs to be registered to monitor Uri in order to switch UI.

    2. If the operation of ContentProvider does not affect the UI, then it doesn't matter. It is also possible to directly operate the DB internally.

    reply
    0
  • 迷茫

    迷茫2017-04-17 17:05:14

    According to the definition of ContentProvider, it is a standard API for data exchange in different applications. It can be used when an application needs to expose data to other applications, and other applications can operate the exposed data through ContentResolver and expose their own through ContentProvider. Data operation interface, other applications can perform corresponding addition, deletion, modification and query operations through this interface. But the essence of the operation through ContentResolver is to call the operation of ContentProvider, and the operation uses the db of SQLiteOpenHelper. So I personally think there is no need to rewrite it, but this is also a personal opinion. You still have to try it yourself and you will know the result.

    reply
    0
  • 天蓬老师

    天蓬老师2017-04-17 17:05:14

    It should be true. Data written directly through data is application private data and cannot be accessed by other applications. However, if the DB file is operated in the SD card, it seems to be accessible.

    reply
    0
  • Cancelreply