get Source Apk Path - Android App

Android examples for App:APK Information

Description

get Source Apk Path

Demo Code


//package com.java2s;
import android.content.Context;

import android.content.pm.ApplicationInfo;

import android.content.pm.PackageManager.NameNotFoundException;

import android.text.TextUtils;

public class Main {

    public static String getSourceApkPath(Context context,
            String packageName) {
        if (TextUtils.isEmpty(packageName))
            return null;

        try {/*from   w ww  .  j a  va  2s  .c  om*/
            ApplicationInfo appInfo = context.getPackageManager()
                    .getApplicationInfo(packageName, 0);
            return appInfo.sourceDir;
        } catch (NameNotFoundException e) {
            e.printStackTrace();
        }

        return null;
    }
}

Related Tutorials