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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:03:16+00:00 2026-05-22T22:03:16+00:00

in my app i have two editbox in which the user types the email

  • 0

in my app i have two editbox in which the user types the email and password. The values are send to an URL and if the return values is success i am moving to a new activity, else if the return value is Email And Password Not Match! i want to show an alert box that emailand pwd mismatches.

For this, after getting the xml file from the network using sax parser i am doing parsing the and if the return value is "Email And Password Not Match!", i am storing this in a constant names as ERROR_VALUE.

i have already stored the value in a String constant as follows

public static String ERROR_CONST   = "Email And Password Not Match!";

now i am comparing those values and showing an alert box,

if (ERROR_CONST.contentEquals(ERROR_VALUE))
  {
       alertbox();
  }

after this i am using the else part to move to a new activity, my app gets crashed at this part only

else if(ERROR_VALUE == null)
{
  Intent myIntent = new Intent(getBaseContext(), Add.class);
  startActivityForResult(myIntent, 0);
  finish();
}
                }

how to use else condition successfully in my app, please help me friends

  • 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-22T22:03:16+00:00Added an answer on May 22, 2026 at 10:03 pm

    Well when comparing 2 strings its always a good idea to use

    s1.compareToIgnoreCase(s2);
    

    reading your post I would suggest you use enum or constants

    public static final ERROR_CODE_INVALIDE_LOGGIN = 1;
    

    to compare rather that strings.

    Comparing strings is tedious (have to be careful that your comparing the characters and not references etc.). As comparing 2 int is easy and takes less time


    I checked quickly in the javaDoc

    contentEquals compares your String to a StringBuffer

    http://download.oracle.com/javase/1.4.2/docs/api/java/lang/String.html#contentEquals(java.lang.StringBuffer)

    as

    http://download.oracle.com/javase/1.4.2/docs/api/java/lang/String.html#compareTo(java.lang.String)

    Compares the actual string letters


    other edit (sorry about that)

    if your code is

    if (ERROR_CONST.contentEquals(ERROR_VALUE))
      {
           alertbox();
      }
    
    
    else if(ERROR_VALUE == null)
    {
      Intent myIntent = new Intent(getBaseContext(), Add.class);
      startActivityForResult(myIntent, 0);
      finish();
    }
    

    then you have a problem when ERROR_VALUE is == null.

    you pass null in contentequals and I’m guessing Java tries to convert null to StringBuffer and crashes.

    what you want to do it

    if(ERROR_VALUE == null)
        {
          Intent myIntent = new Intent(getBaseContext(), Add.class);
          startActivityForResult(myIntent, 0);
          finish();
        }else if (ERROR_CONST. equalsIgnoreCase(ERROR_VALUE))
        {
           alertbox();
        }
    

    this way you avoid any null pointer exceptions and your compare will work just fine

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

Sidebar

Related Questions

I have a cocoa app with two types windows each of which requires a
So In my rails app I have two resources (rentals, and reservations) which belong
I have two forms in my rails app. They both exist in separate tabs
I have two applications in CakePHP, App A an App B. I want that
Is it possible for a single app to have two notifyicons? How can this
I have two domains for example www.male.com and www.female.com which both point to the
I have two NSTimers in my iPhone app. DecreaseTimer works fine, but TimerCountSeconds crashes
I have two applications: 1) A multithreaded cocoa gui app. 2) A unix command
I have two targets in my iPhone application: one for my actual app, and
Is it possible to compare two sounds ? for example app have already a

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.