This question has already been answered:
- How to compare strings in java? 2 answers
Why does the comparison (if) of identical strings show false ?
Code :
File sdPath = Environment.getExternalStorageDirectory(); sdPath = new File(sdPath.getAbsolutePath() + "/папка"); ArrayList<File> files = listFilesWithSubFolders(sdPath); for (File fl: files) { format = fl.getName().substring(fl.getName().lastIndexOf(".")); if(format == ".cfg"){ }else if (format == ".png") { ImageView mImageView; mImageView = (ImageView) findViewById(R.id.imageView2); mImageView.setImageBitmap(BitmapFactory.decodeFile(fl.getPath())); } } For clarity, the screen so that they do not tell me that my lines are different: D:
