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&