Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.os.Environment;

import java.io.File;
import java.io.FileInputStream;

import java.io.IOException;

import java.util.HashMap;
import java.util.Properties;

public class Main {
    public static final String HASHMAPFILEPATH = Environment.getExternalStorageDirectory()
            + "/DCIM/hashMap.properties";
    public static HashMap<String, String> GPSDataMap = new HashMap<>();

    public static void loadHashMapData() throws IOException {
        HashMap<String, String> hashMap = new HashMap<String, String>();
        Properties properties = new Properties();

        File file = new File(HASHMAPFILEPATH);
        if (file.exists()) {
            properties.load(new FileInputStream(HASHMAPFILEPATH));

            for (String key : properties.stringPropertyNames()) {
                hashMap.put(key, properties.getProperty(key));
                GPSDataMap = hashMap;
            }
        } else {
            file.createNewFile();
        }
    }
}