List of usage examples for android.content.pm PackageManager getProviderInfo
public abstract ProviderInfo getProviderInfo(ComponentName component, @ComponentInfoFlags int flags) throws NameNotFoundException;
From source file:com.ericsender.android_nanodegree.popmovie.com.ericsender.android_nanodegree.popmovie.data.TestProvider.java
public void testProviderRegistry() { PackageManager pm = mContext.getPackageManager(); // We define the component name based on the package name from the context and the // MovieProvider class. ComponentName componentName = new ComponentName(mContext.getPackageName(), MovieProvider.class.getName()); try {/*from w w w. j a v a2 s .c o m*/ // Fetch the provider info using the component name from the PackageManager // This throws an exception if the provider isn't registered. ProviderInfo providerInfo = pm.getProviderInfo(componentName, 0); // Make sure that the registered authority matches the authority from the Contract. assertEquals( "Error: MovieProvider registered with authority: " + providerInfo.authority + " instead of authority: " + MovieContract.CONTENT_AUTHORITY, providerInfo.authority, MovieContract.CONTENT_AUTHORITY); } catch (PackageManager.NameNotFoundException e) { // I guess the provider isn't registered correctly. assertTrue("Error: MovieProvider not registered at " + mContext.getPackageName(), false); } }