public static final Uri PREFERAPN_URI = Uri.parse("content://telephony/carriers/preferapn");
/*
* return current apn name of system.
*/
private String getCurrentApn() {
int id = 0;
Cursor cursor = getContentResolver().query(PREFERAPN_URI, new String[] {"_id"},
null, null, Telephony.Carriers.DEFAULT_SORT_ORDER);
if (null != cursor && cursor.getCount() > 0) {
cursor.moveToFirst();
id = cursor.getInt(0);
}
cursor.close();
String where = "_id = " + id;
cursor = getContentResolver().query(Telephony.Carriers.CONTENT_URI, new String[] {
"_id", "name", "apn", "type"}, where, null,
Telephony.Carriers.DEFAULT_SORT_ORDER);
String currentApn = "";
if (null != cursor && cursor.getCount() > 0) {
cursor.moveToFirst();
currentApn = cursor.getString(cursor.getColumnIndexOrThrow("apn"));
}
cursor.close();
return currentApn;
}
/*
* return current apn name of system.
*/
private String getCurrentApn() {
int id = 0;
Cursor cursor = getContentResolver().query(PREFERAPN_URI, new String[] {"_id"},
null, null, Telephony.Carriers.DEFAULT_SORT_ORDER);
if (null != cursor && cursor.getCount() > 0) {
cursor.moveToFirst();
id = cursor.getInt(0);
}
cursor.close();
String where = "_id = " + id;
cursor = getContentResolver().query(Telephony.Carriers.CONTENT_URI, new String[] {
"_id", "name", "apn", "type"}, where, null,
Telephony.Carriers.DEFAULT_SORT_ORDER);
String currentApn = "";
if (null != cursor && cursor.getCount() > 0) {
cursor.moveToFirst();
currentApn = cursor.getString(cursor.getColumnIndexOrThrow("apn"));
}
cursor.close();
return currentApn;
}