Android Properties Read findBuildPropValueOf(String prop)

Here you can find the source of findBuildPropValueOf(String prop)

Description

find Build Prop Value Of

Declaration

public static String findBuildPropValueOf(String prop) 

Method Source Code

//package com.java2s;

import java.io.FileInputStream;

import java.io.IOException;

import java.util.Properties;

import android.util.Log;

public class Main {
    public static String findBuildPropValueOf(String prop) {
        String mBuildPath = "/system/build.prop";
        String DISABLE = "disable";
        String value = null;//from  w  w  w .  j a  v  a  2 s .  com
        try {
            //create properties construct and load build.prop
            Properties mProps = new Properties();
            mProps.load(new FileInputStream(mBuildPath));
            //get the property
            value = mProps.getProperty(prop, DISABLE);
            Log.d("TAG",
                    String.format(
                            "Helpers:findBuildPropValueOf found {%s} with the value (%s)",
                            prop, value));
        } catch (IOException ioe) {
            Log.d("TAG", "failed to load input stream");
        } catch (NullPointerException npe) {
            //swallowed thrown by ill formatted requests
        }

        if (value != null) {
            return value;
        } else {
            return DISABLE;
        }
    }
}

Related

  1. getProperties(String propsFile, boolean addToSystemProps)
  2. loadPropertiyFile(String file)
  3. propertiesToString(Properties p)
  4. readPropertyFile(String filePath)
  5. toProperties(String fileName)
  6. findBuildPropValueOf(String prop)