检查APN

/**
	 * 对系统的apn数据库表进行遍历,若没有cmnet则创建改apn,若存在则设置cmnet为当前的apn
	 * 
	 * @param context
	 **/
	public static void detectSystemApn(final Context context) {
		Cursor c = context.getContentResolver().query(APN_TABLE_URI, null,
				null, null, null);
		// 检测系统apn,若没有apn则默认添加一个cmnet的apn;
		if (c == null) {
			InsertAPN(context, APNNAME, APN);
			return;
		}
		// 遍历系统apn,若存在cmnet apn 设置cmnet为当前的apn
		if (c.moveToFirst()) {
			do {
				String row = "";
				int i = c.getColumnIndex("name");
				row += c.getString(i);
				if (row.equals("CMNET")) {
					// 获得 cmnet apn的id
					int apn_id = Integer.parseInt(c.getString(c
							.getColumnIndex("_id")));
					c.close();
					// 修改apn设置
					// updateApn(context,apn_id);
					// 设置cment为当前的apn
					SetNowAPN(context, apn_id);
					return;
					// return true;
				}
			} while (c.moveToNext());
		}
		c.close();
		// 遍历系统apn,不存在cmnet apn 添加一个cmnet的apn
		InsertAPN(context, APNNAME, APN);
	}

 

你可能感兴趣的:(C++,c,C#)