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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:43:05+00:00 2026-05-27T12:43:05+00:00

I have a if statement that does not work, it doesn’t check its condition

  • 0

I have a if statement that does not work, it doesn’t check its condition even if it is correct and I can’t understand this behavior.
please help me to find the error.
this is my code:

public Dialog onCreateDialog(int id) {
      AlertDialog.Builder alert = new AlertDialog.Builder(this);
     final SharedPreferences userPreferences = this.getSharedPreferences("strings", MODE_PRIVATE);
     final Editor edit = userPreferences.edit();

     switch (id) {
     case 1:
            alert.setTitle(lang_menu[3]);//"Gestione Preferiti"
         alert.setIcon(R.drawable.ic_menu_star);
         final String namesFav = userPreferences.getString("Name_Fav", "");
         final String locfav = userPreferences.getString("Loc_Fav", "");
         final String numfav = userPreferences.getString("Num_Fav", "");
         final String subnumfav = userPreferences.getString("SubNumFav", "");

        final String[] namesFavs = namesFav.split(";");
        final String[] locfavs= locfav.split(";");
        final String[] numfavs= numfav.split(";");
        final String[] subnumfavs = subnumfav.split(";");

         alert.setSingleChoiceItems(namesFavs, -1, new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog, int item) {
                pos = item;

            }
        });
        alert.setPositiveButton(lang_btn[2], new DialogInterface.OnClickListener() //"Visualizza"
        {
            public void onClick(DialogInterface dialog, int whichButton)
            {
              //if (SharedCode.isOnline(content)){
                 if (pos == -1){
                    Toast.makeText(content.getApplicationContext(), lang_error[2], Toast.LENGTH_LONG).show();//"Nessun preferito selezionato"
                 }else{
                    if (namesFavs[pos] == ""){
                        Toast.makeText(content.getApplicationContext(), lang_error[3], Toast.LENGTH_SHORT).show();//"Pagina inesistente"

                    }else{
                        prova= locfavs[pos];
                        SharedCode.loc = locfavs[pos].;
                        SharedCode.num = Short.parseShort(numfavs[pos]);
                        SharedCode.sub_num= Byte.parseByte(subnumfavs[pos]);
//-----------------------------------------------------------------------------------
                        if (SharedCode.loc == "aertel"){//this is the if that doesn't work
                            IrelandTeletext.getPage(content);
                        }
///////////////////////---------------------------------------------------------------
                    }


                }
                pos = -1;
            }
        });
break;
}
AlertDialog MyAlert  = alert.create();
    return MyAlert;
 }

enter image description here

  • 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-27T12:43:05+00:00Added an answer on May 27, 2026 at 12:43 pm

    You can’t compare Strings like that in Java. You should use String.equals(…). The explanation for this quite simple. The == operator checks if the objects are the same. Those strings are different objects with the same value.

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

Sidebar

Related Questions

Someone please help me understand why this binding does not work... I have a
I have a SQL statement (MS SQL Server 2005) that does a simple calculation
I have some SQL that does an order by case statement. It works fine.
I have LINQ statement that looks like this: return ( from c in customers
In an Oracle 10g environment, I have a statement that needs to be executed
I have a SQL statement that looks like: SELECT [Phone] FROM [Table] WHERE (
I have a delete statement that's going against one of my core application tables.
I have an UPDATE statement that's intended to update a status field for a
I have a sql statement that uses Difference => http://msdn.microsoft.com/en-us/library/ms188753.aspx I do this in
I have an IF statement that consists of two separate function calls passing values

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.