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.SharedPreferences;

import android.preference.PreferenceManager;

import java.util.regex.Pattern;

public class Main {
    private static final String Viva_Current_Location = "VivaCurrentLocation";

    public static double[] getVivaCurrentLocation(Context context) {
        String loc = getPreferences(context).getString(Viva_Current_Location, "0,0");
        String[] locArray = loc.split(Pattern.quote(","));
        return new double[] { Double.parseDouble(locArray[0]), Double.parseDouble(locArray[1]) };
    }

    /**
     * Default Preference Helper
     * @param context - the calling application context.
     * @return Shared Preferences
     */
    private static SharedPreferences getPreferences(Context context) {
        return PreferenceManager.getDefaultSharedPreferences(context);
    }
}