Android File system

Put your problem here if it does not fit any of the other categories.

Android File system

Postby Niketa » Thu Oct 16, 2008 1:41 pm

hi,

I want to ask some question regarding android File system.

1. From the command prompt, I am making a folder with command
mkdir folderName
in a already exists folder named "dev".
Now when i write the code to get only Image files then i cant get the Image files from my folder. It vomits
if part from which i am checking file if directory ? and if it is other than directory it goes to else part.
My own created folder is directly goes to else part though it is a directory.
and if i only check the single my file like "folderName.isDirectory" than it gives true.

2. i am not getting the Image files from the data folder using the java code from the emulator. so what should i
do to get it.
[code]

private void browseToRoot1(File rootDir) {
two = new String[0][2];
/*
File f =new File("/dev/folderName");
Log.i(tag,"type-----"+f.isDirectory());
//this returns true.
*/
try {
dir = rootDir.list();
for (int i = 0; i < dir.length; i++)
{
File f = new File(dir[i]);
Log.i(tag,"root file Name"+f.getName());
if(f.isDirectory())
{
Log.i(tag,"to check directory");
CheckDir(f);
}
else
{
if(f.isFile()&&f.canRead()&& f.exists()&& f.getName().endsWith("jpg")
|| f.getName().endsWith("png")
|| f.getName().endsWith("gif"))
{
Log.i(tag,"image file"+f.getName());
add_to_array(f);
}
}
}
} catch (Exception e) {
Log.i(tag, "Exception in browse" + e.getMessage());
}

}

//to search directory
File CheckDir(File f1)
{
try
{
String s[] = f1.list();
if (s.length > 0)
{
for (int j = 0; j < s.length; j++)
{

File f2 = new File(s[j]);


if(f2.isDirectory())
{

CheckDir(f2);
}
else
{

if(f2.getName().endsWith("jpg")
|| f2.getName().endsWith("png")
|| f2.getName().endsWith("gif"))
{

}
}


}

}

}catch(Exception e)
{
Log.i(tag,"error------------"+e);

}
return f1;
}







I do not know the reason, please can any one help?


Thanks.
Niketa
Developer
Developer
 
Posts: 36
Joined: Wed Sep 17, 2008 12:37 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Google Feedfetcher and 20 guests