要刪除您應該刪除的APN定義連接,根據此:http://www.mail-archive.com/[email protected]/msg62089.html
這個倉庫應該有你需要的一切:http://code.google.com/p/apndroid/
不管怎樣,下面是一些片斷我找到了......
讀取當前APN:
Cursor cursor =
getContentResolver().(Uri.parse("content://telephony/
carriers"),
null, null,
null, null);
StringBuffer sb = new StringBuffer();
cursor.moveToFirst();
do{
sb.append("_id =").append(cursor.getString(0)).append(" , ");
sb.append("name=").append(cursor.getString(1)).append(" , ");
sb.append("numeric=").append(cursor.getString(2)).append(" , ");
sb.append("mcc=").append(cursor.getString(3)).append(" , ");
sb.append("mnc=").append(cursor.getString(4)).append(" , ");
sb.append("apn=").append(cursor.getString(5)).append(" , ");
sb.append("user=").append(cursor.getString(6)).append(" , ");
sb.append("server=").append(cursor.getString(7)).append(" , ");
sb.append("password=").append(cursor.getString(8)).append(" ,
");
sb.append("proxy=").append(cursor.getString(9)).append(" , ");
sb.append("port=").append(cursor.getString(10)).append(" , ");
sb.append("mmsproxy=").append(cursor.getString(11)).append(" ,
");
sb.append("mmsport=").append(cursor.getString(12)).append(" ,
");
sb.append("mmsc=").append(cursor.getString(13)).append(" , ");
sb.append("type=").append(cursor.getString(14)).append(" , ");
sb.append("current=").append(cursor.getString(15)).append(" ,
");
sb.append("\n--- BLOCK ---\n");
}while(cursor.moveToNext());
添加APN這樣的:
//Trying to Insert a Custom Setting to Telephony db
ContentValues values = new ContentValues();
values.put("_id","3");
values.put("name","Ramesh");
values.put("numeric","310995");
values.put("mcc","315");
values.put("mnc","995");
values.put("apn","email");
values.put("user","elkjop");
values.put("server","www.moota.com");
values.put("password","elkjop");
values.put("proxy","12");
values.put("port","12");
values.put("mmsproxy","12");
values.put("mmsport","12");
values.put("mmsc","12");
values.put("type","a");
values.put("current","a");
//Adding Values using the Content Resolver
getContentResolver().insert(Uri.parse("content://telephony/
carriers"), values);
我發現這個在這裏:https://groups.google.com/forum/#!topic/android-developers/fYwf_mhEX3Y
到那個ContentResolver的你可能也刪除它們。
然後,您將刪除APN,然後再重新啓動它,然後按照您的要求進行操作。
插入是成功的,但在設置中不能看到APN,也不能選擇它爲什麼會這樣? – Shardul 2011-08-29 19:22:38