TelephonyProvider 所在AndroidManifest 的配置packages/providers/TelephonyProvider/AndroidManifest.xml 具体提供了apn的数据库的创建,表的创建,增删更新删除等操作。 <provider android:name="TelephonyProvider" android:authorities="telephony" android:exported="true" android:multiprocess="false" />
匹配的MIMETYPE类型
@Override
publicString getType(Uriurl)
{
switch(s_urlMatcher.match(url)){
caseURL_TELEPHONY:
caseURL_TELEPHONY_USING_SUBID:
return"vnd.android.cursor.dir/telephony-carrier";
caseURL_ID:
return"vnd.android.cursor.item/telephony-carrier";
caseURL_PREFERAPN_USING_SUBID:
caseURL_PREFERAPN_NO_UPDATE_USING_SUBID:
caseURL_PREFERAPN:
caseURL_PREFERAPN_NO_UPDATE:
return"vnd.android.cursor.item/telephony-carrier";
default:
thrownewIllegalArgumentException("UnknownURL " + url);
}
}
用的位置:packages/apps/Settings/src/com/android/settings/ApnSettings.java
privatevoidaddNewApn() {
Intentintent = newIntent(Intent.ACTION_INSERT, Telephony.Carriers.CONTENT_URI);
intsubId = mSubscriptionInfo!= null? mSubscriptionInfo.getSubscriptionId()
:SubscriptionManager.INVALID_SUBSCRIPTION_ID;
intent.putExtra("sub_id",subId);
startActivity(intent);
}
@Override
publicbooleanonPreferenceTreeClick(PreferenceScreenpreferenceScreen, Preference preference) {
intpos = Integer.parseInt(preference.getKey());
Uri url =ContentUris.withAppendedId(Telephony.Carriers.CONTENT_URI, pos);
startActivity(newIntent(Intent.ACTION_EDIT, url));
returntrue;
}
位置:
packages/apps/Settings/src/com/android/settings/ApnEditor.java
if(action.equals(Intent.ACTION_EDIT)) {
mUri= intent.getData();
} elseif(action.equals(Intent.ACTION_INSERT)) {
if(mFirstTime|| icicle.getInt(SAVED_POS)== 0) {
mUri= getContentResolver().insert(intent.getData(), newContentValues());
} else{
mUri= ContentUris.withAppendedId(Telephony.Carriers.CONTENT_URI,
icicle.getInt(SAVED_POS));
}
配置文件:
<activityandroid:name="ApnEditor"
android:label="@string/apn_edit">
<intent-filter>
<actionandroid:name="android.intent.action.VIEW"/>
<actionandroid:name="android.intent.action.EDIT"/>
<categoryandroid:name="android.intent.category.DEFAULT"/>
<dataandroid:mimeType="vnd.android.cursor.item/telephony-carrier"/>
</intent-filter>
<intent-filter>
<actionandroid:name="android.intent.action.INSERT"/>
<categoryandroid:name="android.intent.category.DEFAULT"/>
<dataandroid:mimeType="vnd.android.cursor.dir/telephony-carrier"/>
</intent-filter>
</activity>
可以在此文件中通过
Cursorcursor = getContentResolver().query(Telephony.Carriers.CONTENT_URI,newString[] {
"_id","name","apn","type"},where, null,
Telephony.Carriers.DEFAULT_SORT_ORDER);
getContentResolver来调用TelephonyProvider的相关数据库的接口。