My previous purpose is to find all pictures in local system out.
public void searchTargetFile()
{
String[] filterFileExtnew= new String[] {"jpg","jpeg","png","tif"};
File dirRoot= new File( android.os.Environment.getExternalStorageDirectory().getAbsolutePath() );
File[] dirOrFile= dirRoot.listFiles();
if( dirOrFile == null) return;
assert(dirOrFile != null);
for( File f : dirOrFile )
{
if( f.isDirectory() )
{
searchTargetFile( f.getAbsolutePath() );
}
else
{
//Filter out files with certain file extension.
for(String extName: filterFileExt)
{
if( f.getName().endsWith(extName) )
{
newDisplayFile= new DisplayFile(new String( f.getAbsolutePath() ), f.length());
filesArray.add(newDisplayFile);
}
}//for
}//else
}//for
}//method
//DisplayFile is a subclass of File and filesArray is a ArrayList.
By using recursive method, I can filter out all the images with certain file extension in the exteranl storage.
However, I found I don't need some images like another app's icon or some images only belong to these app.
I just want to collect all the pictures generated by different apps: Google Default Camera
,
CandyCamera
, Line Camera
and so on.
I mean users may use various app to take pictures and the pictures may be stored somewhere but I don't know.(?)
How should I set the
dirRoot
path?Or maybe I should use another approach instead of using recursive searching?
- Can I or should I know those app's path?