APN 源码分析 --- 增删改查过程分析

5.3 查询/增加/删除/修改 APN

在手机的设置里,每一张SIM卡对应一个APN界面,这个界面包含了APN信息,并且可以增加,修改,删除等操作。

例如,电信卡对应的APN界面如下,


第一个就是当前默认的APN或者已经连接的APN,第三个APN专门用于发送彩信的。

3.1查询

查询当前默认的APN信息,也就是查询telephony.db数据库的siminfo表

Uri curi = Uri.parse("content://telephony/carriers/preferapn");  
Cursor ccr = mContext.getContentResolver().query(curi, null, null, null, null); 
ccr.moveToFirst();        
String idd = ccr.getString(ccr.getColumnIndex("_id"));       
String named = ccr.getString(ccr.getColumnIndex("name"));
String apnd = ccr.getString(ccr.getColumnIndex("apn"));
		 
String usercurrent = ccr.getString(ccr.getColumnIndex("user"));
String passwordcurrent = ccr.getString(ccr.getColumnIndex("password"));
String authtypecurrent = ccr.getString(ccr.getColumnIndex("authtype"));
String typecurrent = ccr.getString(ccr.getColumnIndex("type"));

查询当期SIM卡对应的APN信息,查询telephony.db数据库的carriers表单,

TelephonyManager iPhoneManager = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
Uri APN_URI = Uri.parse("content://telephony/carriers/");
String iNumeric = iPhoneManager.getSimOperator();
•••
Cursor apnCursor = mContext.getContentResolver().query(APN_URI, new String[] { "_id", "name", "numeric", "apn", "mcc", "mnc&
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值