Sunday, January 22, 2012

[android-developers] How to set the preferred APN through code?

I am trying to set a preferred APN through code. Here's what I'm doing:
 
private static final Uri PREFERRED_CONTENT_URI = Uri.parse("content://telephony/carriers/preferapn");

 

// getCurrentPreferredAPN is an internal function to retrieve the "_id" of the current APN.
String strCurrent = getCurrentPreferredAPN();

ContentValues values =  new ContentValues();

Uri ret;

// create the dummy ID

values.put(SZ_NAME, "blah");values.put(SZ_APN, "blah");

values.put(SZ_TYPE, "blah");

values.put("current", "1");

 

// 'delete' the current entry.
nUpdated = getContentResolver().delete(PREFERRED_CONTENT_URI, "_id=?", new String[] { strCurrent };

// 'insert' a new entry.
ret = getContentResolver().insert(PREFERRED_CONTENT_URI, values);
if(null == ret)

{

Log.i("Add Dummy APN", "Failed");

return;

}

 

The call   ==> "insert" ==>  is always returning null for me.

 

What is the right way of doing this?

 

 

 

 

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate