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 need to store app specific configuration in rails. But it has to be:
In my app i need to save changed values (old and new) when model
We need to interface to 3rd party app, but company behind the app doesn't
I need a simple app to edit database tables. Are there any code generators
In my app users need to be able to enter numeric values with decimal
I'm building a app that need manage money datatype. I'm new on Obj-c, so
I have a LAMP (PHP) web app which need to interface with programs on
I'm currently working on a Silverlight app and need to convert XML data into
I need to change the app name based on what configuration I'm using in
I need to script the creation of app pools and websites on IIS 6.0.

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.