get Download Directory - Android File Input Output

Android examples for File Input Output:Directory

Description

get Download Directory

Demo Code


//package com.java2s;

import android.content.Context;

import android.os.Environment;

import java.io.File;

public class Main {

    public static File getDownloadDir(Context context) {
        return isExternalStorageWritable() ? context
                .getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS)
                : context.getFilesDir();
    }//from  w  ww .j  a  va  2 s.co m

    public static boolean isExternalStorageWritable() {
        String state = Environment.getExternalStorageState();
        return Environment.MEDIA_MOUNTED.equals(state);
    }
}

Related Tutorials