It's an old question, but I was looking at doing something similar recently. With the Build flavours, its really straight forward now.
Specify the BuildConfigField in the gradle file:
productFlavors {
free {
applicationId "com.example.free"
buildConfigField 'String', 'AUTHORITY', '"com.example.free.contentprovider"'
}
paid {
applicationId "com.example.paid"
buildConfigField 'String', 'AUTHORITY', '"com.example.paid.contentprovider"'
}
Specify the provider authority in the manifest:
<provider
android:name=".ContentProvider"
android:authorities="${applicationId}.contentprovider" />
Set the authority in the provider using the BuildConfigField Variable:
public static final String AUTHORITY = BuildConfig.AUTHORITY
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…