Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid If else condition error
    primarykey
    data
    text
    <p>I dont know why the following codition is always reuturning false even when its TRUE. What im comparing is result from a user entered text in a string variable 'classNameGlobal' and a second result from a DB query resulting a string value from a column of table. Whenever i run the control switches to else condition not running the if part -.-</p> <p>Please have a look. </p> <pre><code>String result[]; result = new String[cursor.getCount() - 1]; int i = 0; while (cursor.moveToNext()) { result[i] = cursor.getString(cursor.getColumnIndex("name")); i++; } classNameGlobal = className.getText().toString().toUpperCase().trim(); </code></pre> <p>Note: All if the above code is written in onclick method except for that result array declaration. Also, Im using the same method for string being stored in database i.e. im converting it to upper case and then triminng any extra white spaces !!! Even when im dumping the results from query and tat of user entered string. Both ARE SAME. NOW why do im always keeping getting this else part running but not the if part -.- The method im using to compare the results from database query and user entered string is:</p> <pre><code> for (int b = 0; b &lt; result.length; b++) { if (classNameGlobal == result[b]) { Log.d(TAG, "Inside if condition now : " + result[b] + " \t" + classNameGlobal); db.execSQL("drop table if exists " + classNameGlobal); /* Deleting Code File */ this.deleteFile(classNameGlobal + ".txt"); Toast.makeText( this, classNameGlobal + " Database Dropped Successfully ", Toast.LENGTH_SHORT).show(); break; } else { Toast.makeText( this, "No Such Database Exists", Toast.LENGTH_SHORT).show(); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload