Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.app.Activity;

import android.content.Context;

import android.os.storage.StorageManager;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class Main {
    public static boolean hasExtSdcard(Context context) {
        String[] paths;
        StorageManager service = (StorageManager) context.getSystemService(Activity.STORAGE_SERVICE);
        try {
            Method mMethod = service.getClass().getMethod("getVolumePaths");
            paths = (String[]) mMethod.invoke(service);
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
        return false;
    }
}