ContentProvider query operation process source code analysis (Android Q)

ContentProvider query call process source code analysis (Android Q)


ContentProvider is one of the four major components of Android, which can easily query data across processes, so how does the Android system implement ContentProvider query and other operations?

Example usage of ContentProvider

Let's first look at an example of a ContentProvider call:

    public void readData(String selection) {
        Cursor cursor = null;
        try {
            cursor = context.getContentResolver()
                    .query(getTableUri(), null, selection, null, null);
            ……
        } catch (Exception e) {
            LogX.e(TAG, SUB_TAG, getName() + "; " + e.toString());
        } 
    }

Here, through the getContentResolver() method of the context object, the data stored in the ContentProvider can be manipulated. How to achieve it? We analyze the whole process through the source code.

ContentResolver

The ContentResolver class is a very critical class. When we actually use the data of the ContentProvider, we operate through the instance of this class. </

Guess you like

Origin blog.csdn.net/u011578734/article/details/113728875