0

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.(?)

  1. How should I set the dirRoot path?

  2. Or maybe I should use another approach instead of using recursive searching?

  3. Can I or should I know those app's path?
Alston
  • 2,085
  • 5
  • 30
  • 49
  • If you just want the images from the gallery, check this stackoverflow post http://stackoverflow.com/questions/18590514/loading-all-the-images-from-gallery-into-the-application-in-android – Premsuraj Jul 02 '14 at 11:49
  • No, I also want another type of files like video and documents. It depends on the file extension. – Alston Jul 02 '14 at 12:37

0 Answers0