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 538537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:02:32+00:00 2026-05-13T10:02:32+00:00

I need my app to run on all Android versions, but the Contacts API

  • 0

I need my app to run on all Android versions, but the Contacts API changed in 2.0.

In SDK 1.6 and earlier I use android.provider.Contacts to query the contacts DB, but this does not work in 2.0

Instead, for 2.0 I use android.provider.ContactsContract. This presents a problem: when I have code for ContactsContract, my app will not build for 1.6 and earlier.

Do I need to have two separate versions of my app (one for <= 1.6 and one for 2.0 and later) or is there a way to avoid doing this?

  • 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-13T10:02:32+00:00Added an answer on May 13, 2026 at 10:02 am

    You can support both versions on Android using Java Reflection. Amusingly, the answer to your question can be found in a recent question about reflection used to solve this exact problem:

    Uri baseUri = Contacts.Phones.CONTENT_FILTER_URL;
    try {
        Class<?> c = Class.forName("android.provider.ContactsContract$PhoneLookup");
        baseUri = (Uri) c.getField("CONTENT_FILTER_URI").get(baseUri);
    } 
        catch (Exception e) {
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on an Android app that I want to run on all
I need to make a QT app to run on the startup of an
I have a C#.net app I need to run off a computer. It has
I have a web app (MVC) where I need some automatic service to run
My app need to target API level 7 and above, however I'd like to
I need my app to be able access an third party API who limits
I need my app to create a dialog Seekbar. But I cannot make it
I want to develop an Android application which can run on all ,screen type
I am building an android app for which I need to check the sync
I'm working on developing an app for Android and need to store contact ID's

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.