My app has to check if a certain folder is on the secondary storage when the Android version is 4.4+.
I am using this:
private boolean isPathOnSecondaryStorage(String path) {
boolean res=false;
String secondaryStorage=System.getenv("SECONDARY_STORAGE");
String[] secondaryPaths=secondaryStorage.split(":");
for (int i=0;i<secondaryPaths.length;i++) {
String secondaryPath=secondaryPaths[i].trim();
if (path.contains(secondaryPath)) {
res=true;
}
}
return res;
}
Note that:
path is chosen by the user by means of a file chooser activity, starting from /mnt
the app wants to check what is mounted as usual, like when an external SD-card is inserted in its slot
So I ask whether the above mentioned code will be always able to detect when the path is on a secondary storage, or instead on some devices it could find strange mounting points different from /mnt (Android 4.4+).