Search code examples
androidandroid-version

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 ?


Solution

  • 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