is Install On SD Card by package name - Android Hardware

Android examples for Hardware:SD Card

Description

is Install On SD Card by package name

Demo Code


//package com.java2s;

import android.content.Context;

import android.content.pm.ApplicationInfo;

import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;

public class Main {

    public static boolean isInstallOnSDCard(Context context,
            String packageName) {
        try {/*from   ww  w .  j a va  2  s  . co  m*/
            PackageManager pm = context.getPackageManager();
            ApplicationInfo appInfo = pm.getApplicationInfo(packageName, 0);
            if ((appInfo.flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0) {
                return true;
            }
        } catch (NameNotFoundException e) {
            e.printStackTrace();
        }
        return false;
    }

    public static ApplicationInfo getApplicationInfo(Context context) {
        return context.getApplicationInfo();
    }
}

Related Tutorials