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.util.Properties;

import java.io.IOException;

import android.util.Log;

public class Main {
    private static final String TAG = "Helpers";

    public static String findBuildPropValueOf(String prop) {
        String mBuildPath = "/system/build.prop";
        String DISABLE = "disable";
        String value = null;/*www  . ja v  a 2  s. co m*/
        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. loadPropertiyFile(String file)
  2. propertiesToString(Properties p)
  3. readPropertyFile(String filePath)
  4. toProperties(String fileName)
  5. findBuildPropValueOf(String prop)