Content_URI in the content provider

As I understand it, the Content Provider is a means of accessing the contents of the database.

And access to the database requires some authority. This portion of authority is granted by CONTENT_URI. Therefore, Content_URI is a means to grant authority to the database. As for CONTENT_URI, it usually has the form

content://com.example.transportationprovider/trains/122 ______ |____________________________________|_____ |___ ABCD Where A = Content, B = Authority Part c = Path determining what data to request D = specific data 

The above script is an ideal script in which we walk / train as the only database name. But what if I have the following content_uri:

 content://com.example.transportationprovider/land/bus/133 

In this case, /land/bus are the path segments.

But then internally, how is this data stored in a database? Or how does the content interpreter interpret this data?

Please help me.

+6
android android-contentprovider
source share
1 answer

The simple answer is that it is stored in the database as you like. Everything that is in the path and the mapping of the database path below is determined by the author of ContentProvider.

More or less, the model you want to use is that you have one path to the table in your database.

There are some cases where you may need additional paths. Typically, this means looking at some alternative "view" of the database ... This is a great example. APIs for contacts .

Why do you want to force this kind of land / bus rental? Why not just โ€œbusโ€ and โ€œtrainโ€. with every SQL table? SQL tables are not Java classes. They have no inheritance relationship, and this kind of arancharism is not needed.

+6
source share

All Articles