- 论坛徽章:
- 2
|
增加新的APN节点
//插入一个新的APN接入点
private int InsetAPN()
{
ApnNode checkApn = new ApnNode();
checkApn.setName(apnname);
checkApn.setApn("cmnet");
checkApn.setUser("*");
checkApn.setPassword("*");
checkApn.setServer(server);
checkApn.setMcc(getMCC());
checkApn.setMnc(getMNC());
checkApn.setNumeric(getSimOperator());
int apnd_id = addNewApn(checkApn);
return apnd_id;
}
//增加一个APN
public int addNewApn(ApnNode apnNode)
{
int apnId = -1;
ContentResolver resolver = getContentResolver();
ContentValues values = new ContentValues();
values.put("name", apnNode.getName());
values.put("apn", "cmnet");
values.put("server", "syxzsp.ln");
//values.put("proxy", apnNode.getProxy());
//values.put("port", apnNode.getPort());
values.put("user", "*");
values.put("password", "*");
values.put("mcc", apnNode.getMcc());
values.put("mnc", apnNode.getMnc());
values.put("numeric", apnNode.getNumeric());
// Note: this values need to be update, and for now, it only for XT800.
Cursor c = null;
try
{
Uri newRow = resolver.insert(APN_TABLE_URI, values);
if (newRow != null)
{
c = resolver.query(newRow, null, null, null, null);
int idindex = c.getColumnIndex("_id");
c.moveToFirst();
apnId = c.getShort(idindex);
//Log.d("Robert", "New ID: " + apnId + ": Inserting new APN succeeded!");
}
}
catch (Exception e)
{
finish();
e.printStackTrace();
}
if (c != null)
c.close();
return apnId;
} |
|