Alle Bilder von der SD-Karte auflisten.

Hallo, ich entwickle Android Gallery App. Ich rufe die Bilder aus einem Ordner auf einer SD-Karte ab und zeige sie in einer Rasteransicht wie unten dargestellt an

public static ArrayList<String> getFilePaths()
{
    ArrayList<String> filePaths = new ArrayList<String>();

    File directory = new File(android.os.Environment.getExternalStorageDirectory() + File.separator + AppConstant.PHOTO_ALBUM);

    // check for directory
    if (directory.isDirectory())
    {
        // getting list of file paths
        File[] listFiles = directory.listFiles();

        // Check for count
        if (listFiles.length > 0) 
        {

            for (int i = 0; i < listFiles.length; i++)
            {

                String filePath = listFiles[i].getAbsolutePath();

                if (IsSupportedFile(filePath)) 
                {
                    // Add image path to array list
                    filePaths.add(filePath);
                }
            }
        } 
        else 
        {
            // image directory is empty
            Toast.makeText(
                    _context,
                    AppConstant.PHOTO_ALBUM
                    + " is empty. Please load some images in it !",
                    Toast.LENGTH_LONG).show();
        }

    } 
    return filePaths;
}


//fetching all image paths
 imagePaths = utils.getFilePaths();
 adapter = new GridViewImageAdapter(GridViewActivity.this, imagePaths, columnWidth);
 // setting grid view adapter
 gridView.setAdapter(adapter);

Ich möchte alle Bilder von der SD-Karte anzeigen nicht nur in einem bestimmten Ordner. Ich bin nicht sicher, wie es geht.

Bitte helfen Sie. Vielen Dank!

Antworten auf die Frage(5)

Ihre Antwort auf die Frage