get App Source Dir - Android App

Android examples for App:App Information

Description

get App Source Dir

Demo Code


//package com.java2s;

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

import android.util.Log;

public class Main {
    private static final String TAG = "AppUtil";

    public static String getAppSourceDir(String packageName,
            PackageManager pm) {//ww w  . j  a  v  a  2  s  . c  o  m
        ApplicationInfo applicationInfo = null;
        try {
            applicationInfo = pm.getApplicationInfo(packageName, 0);
        } catch (NameNotFoundException e) {
            Log.e(TAG, "getAppSourceDir:" + packageName
                    + " name not found.");
            e.printStackTrace();
        }
        return applicationInfo.sourceDir;
    }
}

Related Tutorials