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

  • Home
  • SEARCH
  • 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 6800979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:02:28+00:00 2026-05-26T19:02:28+00:00

I am getting below error. java.lang.NullPointerException 11-14 16:46:59.093: E/AndroidRuntime(4064): at android.content.ContextWrapper.getContentResolver(ContextWrapper.java:90) Using below code.

  • 0

I am getting below error.

java.lang.NullPointerException
11-14 16:46:59.093: E/AndroidRuntime(4064):     at android.content.ContextWrapper.getContentResolver(ContextWrapper.java:90)

Using below code.

public String getContactNameFromNumber(String number) {
        // define the columns I want the query to return
        String[] projection = new String[] {
                Contacts.Phones.DISPLAY_NAME,
                Contacts.Phones.NUMBER };


        // encode the phone number and build the filter URI
        Uri contactUri = Uri.withAppendedPath(Contacts.Phones.CONTENT_FILTER_URL, Uri.encode(number));

        // query time
        Cursor c = getContentResolver().query(contactUri, projection, null,
                null, null);

        // if the query returns 1 or more results
        // return the first result
        if (c.moveToFirst()) {
            String name = c.getString(c
                    .getColumnIndex(Contacts.Phones.DISPLAY_NAME));
            return name;
        }

Any one has Idea why I am getting this error.

Thank You.

  • 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-26T19:02:29+00:00Added an answer on May 26, 2026 at 7:02 pm

    You can try this code:

    String address="3791783465"; //phone number you already have
    
    Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(address));           
    Cursor cs= context.getContentResolver().query(uri, new String[]{PhoneLookup.DISPLAY_NAME},null,null,null);
    
    if(cs.getCount()>0)
    {
         cs.moveToFirst();    
         Toast.makeText(context,cs.getString(cs.getColumnIndex(PhoneLookup.DISPLAY_NAME),Toast.LENGTH_SHORT).show();
         cs.close();
    }
    else
         Toast.makeText(context,"Unknown",Toast.LENGTH_SHORT).show();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In Android Emulator i am getting below Logcat Error: 03-11 04:44:56.663: ERROR/AndroidRuntime(403): java.lang.RuntimeException: Unable
I'm trying to build a java application with gcj but getting the error below.
I'm getting the following error on the line of code below: Syntax error (missing
I’m getting system error when I try to compile the code below on Visual
Multi-Test TestNG.xml file results in java.lang.NullPointerException Hello Quality Team, I need help getting TestNG
I have added the library ksoap2-android-assembly-2.4-jar-with-dependencies.jar but i am getting below error : Exception
I am getting this error: symbol : constructor JTable(float[][],java.lang.String[]) location: class javax.swing.JTable table =
I am getting below error in logcat. > E/AndroidRuntime( 3197): Uncaught handler: thread main
I was changing the vc++ include directory with new paths suddenly getting below error
I am getting the below error when executing my application on a Windows XP

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.