Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import android.content.Context;
import android.content.res.AssetManager;
import android.content.res.Resources;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class Main {
    /**
     * Gets properties from Assets
     *
     * @param name    Properties file
     * @param context Context
     * @return Properties
     */
    public static Properties getProperties(String name, Context context) {
        Resources resources = context.getResources();
        AssetManager assetManager = resources.getAssets();
        Properties properties = null;

        // Read from the /assets directory
        try {
            InputStream inputStream = assetManager.open(name);
            properties = new Properties();
            properties.load(inputStream);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return properties;
    }
}