Code example for MockContentResolver

Methods: addProvider

0
        SynchronousContactsProvider2.resetOpenHelper(); 
    } 
 
    public void testPerformance() { 
        final Context targetContext = getContext();
        MockContentResolver resolver = new MockContentResolver();
        MockContext context = new MockContext() {
            @Override 
            public Resources getResources() {
                return targetContext.getResources();
            } 
 
            @Override 
            public String getPackageName() {
                return "no.package"; 
            } 
        }; 
        RenamingDelegatingContext targetContextWrapper = new RenamingDelegatingContext(context,
                targetContext, "perf_imp.");
        targetContextWrapper.makeExistingFilesAndDbsAccessible();
        IsolatedContext providerContext = new IsolatedContext(resolver, targetContextWrapper);
        SynchronousContactsProvider2 provider = new SynchronousContactsProvider2();
        provider.setDataWipeEnabled(false);
        provider.attachInfo(providerContext, null);
        resolver.addProvider(ContactsContract.AUTHORITY, provider);
 
        ContentProvider callLogProvider = new TestCallLogProvider();
        callLogProvider.attachInfo(providerContext, null);
        resolver.addProvider(CallLog.AUTHORITY, callLogProvider);
 
        LegacyContactImporter importer = new LegacyContactImporter(providerContext, provider);
 
        provider.wipeData();