Munir Hoque
Munir Hoque

Reputation: 365

How to get Custom SW version number of android

I have a Marshmallow device. It has custom built SW. enter image description here

I have seen the build.prop file. There I can perceive the Software version name comes from ro.custom.build.version

enter image description here

My question is - how can I get the "ro.custom.build.version" information programmatically in my application ?

Upvotes: 0

Views: 1621

Answers (3)

Munir Hoque
Munir Hoque

Reputation: 365

I got the answer. It is very simple - First, I created a function to read from SystemProperties.

public String getSystemProperty(String key) {
    String value = null;

    try {
        value = (String) Class.forName("android.os.SystemProperties")
                .getMethod("get", String.class).invoke(null, key);
    } catch (Exception e) {
        e.printStackTrace();
    }

    return value;
}

And then called the function with "ro.custom.build.version" as a key

getSystemProperty("ro.custom.build.version");

Special thanks to @sasikumar for giving me the hint

Upvotes: 1

ʌɐɥqıɐʌ
ʌɐɥqıɐʌ

Reputation: 147

Check android.os.Build.VERSION. You can use INCREMENTAL.

Upvotes: 0

ZaptechDev Kumar
ZaptechDev Kumar

Reputation: 164

You have to do as below :

PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
String version = pInfo.versionName;

To get the Version code, Use as below :

int verCode = pInfo.versionCode;

Upvotes: 0

Related Questions