Java tutorial
//package com.java2s; //License from project: Open Source License import android.content.Context; import android.content.pm.ApplicationInfo; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.os.Environment; public class Main { public static boolean isInstalledOnSdCard(Context context) { // check for API level 8 and higher if (isCompatible(8)) { PackageManager pm = context.getPackageManager(); try { PackageInfo pi = pm.getPackageInfo(context.getPackageName(), 0); ApplicationInfo ai = pi.applicationInfo; return (ai.flags & 0x00040000 /* * ApplicationInfo. * FLAG_EXTERNAL_STORAGE */) == 0x00040000 /* * ApplicationInfo. * FLAG_EXTERNAL_STORAGE */; } catch (NameNotFoundException e) { // ignore } } // check for API level 7 - check files dir try { String filesDir = context.getFilesDir().getAbsolutePath(); if (filesDir.startsWith("/data/")) { return false; } else if (filesDir.contains(Environment.getExternalStorageDirectory().getPath())) { return true; } } catch (Throwable e) { // ignore } return false; } public static boolean isCompatible(int apiLevel) { return android.os.Build.VERSION.SDK_INT >= apiLevel; } }