,
, ( ), , .
:
File extStore = Environment.getExternalStorageDirectory();
my_birthday_moovie001 , unnamed,
String NameOfFile = "unnamed";
videos, Downloads,
String PathWithFolder = extStore + "/Download/";
,
private List<String> getListFiles(File parentDir) {
ArrayList<String> inFiles = new ArrayList<String>();
File[] files = parentDir.listFiles();
for (File file : files) {
if (file.isDirectory()) {
inFiles.addAll(getListFiles(file));
} else {
String AbsolutePath = file.getAbsolutePath();
String nameofFile = AbsolutePath.substring(AbsolutePath.lastIndexOf("/") + 1, AbsolutePath.length());
String fileNameWithoutExtension = nameofFile.substring(0, nameofFile.lastIndexOf('.'));
inFiles.add(fileNameWithoutExtension);
}
}
return inFiles;
}
,
List<String> files = getListFiles(new File(PathWithFolder));
for, file
for (int i = 0; i<=files.size()-1; i++){
if(PathWithFolder.equals(files.get(i))) {
Toast.makeText(MainActivity.this, "You got it!", Toast.LENGTH_SHORT).show();
}
else{
Toast.makeText(MainActivity.this, "You don't.", Toast.LENGTH_SHORT).show();
}
}
, @Zain Ul Abidin getListFiles(), :
String fileExtension = nameofFile.substring(nameofFile.lastIndexOf("."));
, .