Black_Pearl
Black_Pearl

Reputation: 11

Android - How To Access A Directory On Server

Hi I am Showing Images in GalleryView from SD card . But I want to fetch from a directory resides on a server . here is my Code

 public 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) {

            // loop through all files
            for (int i = 0; i < listFiles.length; i++) {

                // get file path
                String filePath = listFiles[i].getAbsolutePath();

                // check for supported file extension
                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();
        }

    } else {
        AlertDialog.Builder alert = new AlertDialog.Builder(_context);
        alert.setTitle("Error!");
        alert.setMessage(AppConstant.PHOTO_ALBUM
                + " directory path is not valid! Please set the image directory name AppConstant.java class");
        alert.setPositiveButton("OK", null);
        alert.show();
    }

    return filePaths;
} 

In File directory = new file how can I use a directory from server instead of SD card. Thanks in Advance

Upvotes: 1

Views: 106

Answers (0)

Related Questions