I am accessing the assets folder of installed applications from my application. I am able to access the assets folder of every installed application but it returns me with some folder & some files. If it returns me only files then there is no problem I am able to access those files but how could I come to know that is this the file or folder which is I am accessing?
Asked
Active
Viewed 396 times
0
-
Have you tried this solution http://stackoverflow.com/q/4820816/1645319 ? – Taras Shevchuk Sep 18 '12 at 07:26
1 Answers
0
If you want to check if it's a file/directory then you could do something like this:
File file = new File(filepath);
if(file.isDirectory())
{
//Do something if it's a directory
}
else
{
//Do something else if it's a file
}
If you want to check all the files in a directory you can do:
File path = new File("/mnt/sdcard/something");
if( path.exists() ) {
File[] files = path.listFiles();
if (files == null) {
//Break
}
for(int i = 0; i < files.length; i++) {
if(files[i].isDirectory()) {
//Logic if directory
}
else {
//Logic if file
}
}
If you want to know if a filepath contains a word of some installed file then you can check:
if(filepath.contains(stringToLookFor))
{
//Logic if file contains part of the string
}

Anders Vedal Pettersen
- 360
- 1
- 3
- 11