I use the following code in oder to get the preferred apn of the device:
DefaultHttpClient http = new DefaultHttpClient();
Cursor mCursor = ctx.getContentResolver().query(Uri.parse("content://telephony/carriers/preferapn"), new String[] { "name", "proxy", "port"},null, null, null);
if a proxy is set i modify my webrequest
if (mCursor != null) {
            try {
                if (mCursor.moveToFirst()) {
                    // String name = mCursor.getString(0);
                    String proxy = mCursor.getString(1);
                    String port = mCursor.getString(2);
                    if (proxy != null) {
                        if (!proxy.equals("")) {
                            HttpHost proxys = new HttpHost(proxy, Integer.parseInt(port));
                            http.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxys);
                        }
                    }
                }
            } finally {
                try {
                    mCursor.close();
                } catch (Exception e) {
                    mCursor = null;
                }
                mCursor = null;
            }
        }
since Android 4.2 the code failed due to a security exception, neither the user non the Process have the permission WRITE_APN_SETTINGS. I added and but nothing works. Does anybody know how to fix that?