I have two lists - one which returns a list of all folders and one which returns a list of recent folders. What I’d like to do is compare each list to each other - and if a match is found: display a toast.
My current code is as follows:
boolean currentFolderFound = false;
if (mAllFolderListCursor != null) {
final String folderName = mSelectedFolderUri.toString();
if (mAllFolderListCursor.moveToFirst()) {
do {
final Folder f = mAllFolderListCursor.getModel();
if (!isFolderTypeExcluded(f)) {
if (f.folderUri.equals(mRecentFolders)) {
Toast.makeText(getApplicationContext(), "MATCH FOUND",
Toast.LENGTH_LONG).show();
}
}
} while (!currentFolderFound && mAllFolderListCursor.moveToNext());
}
}
I believe I’ve coded the line: if (f.folderUri.equals(mRecentFolders)) {
incorrectly - and I’m wondering how this might be improved to provide the result I am looking for.
Thanks in advance,
Christopher
equals returns true if the objects are actually equal, but in your case they are not. You should use a simple string comparison using compareTo method instead.