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;

public class Main {
    /**
     * Convert a string format float value to Float.
     * 
     * @param context
     * @param resID
     * @param defValue
     * @return
     */
    public final static float getFloatSafely(Context context, int resID, float defValue) {
        try {
            String strValue = context.getResources().getString(resID);
            if (null == strValue) {
                return defValue;
            }

            return Float.parseFloat(strValue);

        } catch (Exception e) {
            e.printStackTrace();
            return defValue;
        }
    }
}