I am having a problem with this piece of code. The if statement on line 6 is being ignored during execution. I have stepped through the code at this point and the value of the variable file[position] is "subjects.dat". However, it is skipping over the steps in this and going to the related else statement. Any ideas why??
dialogButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
if (markComplete.isChecked()) {
String toDelete;
String[] files = fileList();
if (files[position] == "subjects.dat") { //the error occurs at this line
toDelete = files[position + 1];
boolean deleted = deleteFile(toDelete);
if (deleted) {
dialog.dismiss();
} else {
// Do nothing
}
} else {
toDelete = files[position];
boolean deleted = deleteFile(toDelete);
if (deleted) {
dialog.dismiss();
} else {
//Do nothing
}
}
}
}
Thanks!