Android Resource Get getProperties(String name, Context context)

Here you can find the source of getProperties(String name, Context context)

Description

Read a properties file from /assets.

Declaration

public static Properties getProperties(String name, Context context) 

Method Source Code

//package com.java2s;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import android.content.Context;
import android.content.res.AssetManager;
import android.content.res.Resources;
import android.util.Log;

public class Main {
    /** Read a properties file from /assets.  Returns null if it does not exist. */
    public static Properties getProperties(String name, Context context) {
        Resources resources = context.getResources();
        AssetManager assetManager = resources.getAssets();

        // Read from the /assets directory
        try {//from  ww  w  .j  ava2s  . c  om
            InputStream inputStream = assetManager.open(name);
            Properties properties = new Properties();
            properties.load(inputStream);
            return properties;
        } catch (IOException e) {
            Log.e("Gibberbot", "exception reading properties", e);
            return null;
        }
    }
}

Related

  1. getStringArray(int arrayId)
  2. appendRes(StringBuilder sb, Resources res, int resId)