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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T01:01:54+00:00 2026-05-16T01:01:54+00:00

This part of my code checks to see that when the user clicks on

  • 0

This part of my code checks to see that when the user clicks on a contact, the contact actually has a phone number, otherwise a message is displayed and nothing else is done.

I am confused as to where my null pointer exception is coming from….

Uri contactData = data.getData();
     Cursor c =  managedQuery(contactData, null, null, null, null);
     if (c.moveToFirst()) 
     {
       String stringName = c.getString(c.getColumnIndexOrThrow(People.NAME));
       if(c.getColumnIndex(People.NUMBER)!= -1 )
       {
       stringNumber = c.getString(c.getColumnIndexOrThrow(People.NUMBER));
       }
        if((!stringNumber.equals(null)) && (stringNumber.length() >= 12))
        {
         name.setText(stringName);
         number.setText(stringNumber);
        }
        else
        {
         Context context = getApplicationContext();
         CharSequence text = "That contact has an invalid phone number.";
         int duration = Toast.LENGTH_SHORT;

         Toast toast = Toast.makeText(context, text, duration);
         toast.show();
        }

     }

my error is “failure delivering result RESULTINFO” , and it also says it’s a nullpointer exception error in this line:

if((!stringNumber.equals(null)) && (stringNumber.length() >= 12))

earlier in the code, I declare stringNumber to initialize to null. I thought that since the first part of the if evals to false, it wouldn’t even check the second part (which is where I think the error is coming from).

  • 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-16T01:01:55+00:00Added an answer on May 16, 2026 at 1:01 am

    If stringNumber is null, then stringNumber.equals(... will throw a null pointer exception.

    Use if ((stringNumber != null) ... instead.

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

Sidebar

Related Questions

Note : The code in this question is part of deSleeper if you want
It's a part of larger code base, which forces -Werror on gcc. This warning
This is actually a two part question. First,does the HttpContext.Current correspond to the current
Before anyone suggests scrapping the table tags altogether, I'm just modifying this part of
I'm trying to reteach myself some long forgotten math skills. This is part of
This is a part algorithm-logic question (how to do it), part implementation question (how
How can I extract the part of this stream (the one named BLABLABLA) from
I'm working on a document application and part of this application I've to add
I'm writing an app to help facilitate some research, and part of this involves
I'm working on a internal web based tool for my company. Part of this

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.