Code example for ContentProvider

Methods: attachInfo

0
	                getContext(), // The context that file methods are delegated to
	                filenamePrefix);
	        mProviderContext = new MyIsolatedContext(mResolver, targetContextWrapper);
 
	        mProvider = mProviderClass.newInstance();
	        mProvider.attachInfo(mProviderContext, null);
	        assertNotNull(mProvider);
	        mResolver.addProvider(mProviderAuthority, getProvider());
	    } 
 
	  public static <T extends ContentProvider> ContentResolver newResolverWithContentProviderFromSql(
	            Context targetContext, String filenamePrefix, Class<T> providerClass, String authority,
	            String databaseName, int databaseVersion, String sql)
	            throws IllegalAccessException, InstantiationException { 
	        MockContentResolver resolver = new MockContentResolver();
	        RenamingDelegatingContext targetContextWrapper = new RenamingDelegatingContext(
	                new MockContext(), // The context that most methods are delegated to
	                targetContext, // The context that file methods are delegated to
	                filenamePrefix);
	        Context context = new IsolatedContext(resolver, targetContextWrapper);
	        DatabaseUtils.createDbFromSqlStatements(context, databaseName, databaseVersion, sql);