Android, content provider in library project

百般思念 提交于 2019-12-05 02:32:03

I subclassed UriMatcher with something like this :

private static final UriMatcher sUriMatcher
        = new UriMatcher(UriMatcher.NO_MATCH){
    @Override
    public int match(Uri uri) {
        return super.match(uri.buildUpon().authority(AUTHORITY).build());
    }       
};

The app which uses the library should declare the provider in the manifest with it's own authority string.

You can also replace the public static Uri objects in your model classes with a getUri(Context c) function which creates the Uri appropriate for THAT application.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!