Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6726551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:56:26+00:00 2026-05-26T09:56:26+00:00

Someone know if there’s a programmatically way to use a specific defined APN on

  • 0

Someone know if there’s a programmatically way to use a specific defined APN on the device which is not the default one?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T09:56:27+00:00Added an answer on May 26, 2026 at 9:56 am

    You can programmatically query and set the preferred APN using the uri content://telephony/carriers/preferapn. To set a new preferred APN you have to pass in the database ID of an existing APN entry. The following function can do this if you pass in the display name of the APN (eg: setPreferredApn(context, "Giffgaff");)

    public static final Uri APN_TABLE_URI = Uri.parse("content://telephony/carriers");
    public static final Uri APN_PREFER_URI = Uri.parse("content://telephony/carriers/preferapn");
    
    public static boolean setPreferredApn(Context context, String name) {
        boolean changed = false;
        String columns[] = new String[] { Carriers._ID, Carriers.NAME };
        String where = "name = ?";
        String wargs[] = new String[] {name};
        String sortOrder = null;
        Cursor cur = context.getContentResolver().query(APN_TABLE_URI, columns, where, wargs, sortOrder);
        if (cur != null) {
            if (cur.moveToFirst()) {
                ContentValues values = new ContentValues(1);
                values.put("apn_id", cur.getLong(0));
                if (context.getContentResolver().update(APN_PREFER_URI, values, null, null) == 1)
                    changed = true;
            }
            cur.close();
        }
        return changed;
    }
    

    I guess I should add that you need WRITE_APN_SETTINGS permission and need to import android.provider.Telephony and android.provider.Telephony.Carriers

    UPDATE FOR 4.0+

    This facility became disabled with the release of Android 4.0 (ICS). Enabling the WRITE_APN_SETTINGS permission has no effect on allowing you to set the APN any more. See this question for some relevant links. On the API page it now states explicitly this permission is not for external use and this is enforced internally.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does someone know if there is a way to pack everything-application related into one
This is a very narrow and specific question, but I know there are someone
Does someone happens to know if there is a way to retrieve the contents
I know there must be a way to do this, and perhaps someone has
I know there are emulators, but is this good enough? If someone is serious
In jQuery ajax function there is xhr option. Does someone know more details, usability
Wanted to know if someone had a suggestion on code or maybe there's a
I know this is a simple question for someone out there, but I have
Is there a way to just have something show? I know there's the effect
I would like to know if there is a way to prevent PHP from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.