Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import android.content.Context;
import android.content.SharedPreferences;

import java.util.HashMap;

public class Main {
    public static HashMap<String, String> restoreDistanceAndLocation(Context context) {
        SharedPreferences sharedPref = context.getSharedPreferences("DistanceAndLocation", Context.MODE_PRIVATE);
        String[] keyList = { "longitude", "latitude", "kmTravelled" };
        HashMap<String, String> values = new HashMap<>();
        for (String key : keyList)
            values.put(key, sharedPref.getString(key, null));
        return values;
    }
}