get Bundle Version - Android Android OS

Android examples for Android OS:Bundle Get

Description

get Bundle Version

Demo Code


//package com.java2s;

import android.content.Context;

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

public class Main {
    private static Context context;

    public static String getBundleVersion() {
        PackageInfo pInfo;/*w  w  w.ja  va2 s  .c  o  m*/
        String version = new String();
        try {
            PackageManager packageManager = context.getPackageManager();
            pInfo = packageManager.getPackageInfo(context.getPackageName(),
                    0);
            version = pInfo.versionName;
        } catch (NameNotFoundException e) {
            e.printStackTrace();
        }

        return version;
    }
}

Related Tutorials