content: import React, { Component } from 'react';
  import { AppRegistry, Text, View, AsyncStorage } from 'react-native';
  
  // List of setting variables
  var selectedLocation = 'Helsinki';
  var gpsOn = 'false';
  var metric = true;
  var mapType = 'pressure'
  var curLat = "60.2";
  var curLong = "24.9";
  
  class SettingsStorage {
  
    static async initItem(settingName, defValue) {
      var ret;
      try {
        const value = await AsyncStorage.getItem('@MySuperStore:' + settingName);
        if (value !== null){
          ret = value;
          return ret;
        } else {
          try {
            await AsyncStorage.setItem('@MySuperStore:' + settingName, defValue);
          } catch (error) {
            // Error saving data
          }
        }
      } catch (error) {
        try {
          await AsyncStorage.setItem('@MySuperStore:' + settingName, defValue);
        } catch (error) {
          // Error saving data
        }
      }
      return defValue;
    }
  
    static async init() {
      selectedLocation = await this.initItem('selectedLocation', selectedLocation);
      gpsOn = await this.initItem('gpsOn', gpsOn);
      mapType = await this.initItem('mapType', mapType);
      curLat = await this.initItem('curLat', curLat);
      curLong = await this.initItem('mapType', curLong);
    }
  
    static getSelectedLocation() {
      return selectedLocation;
    }
  
    static async setSelectedLocation(loc) {
      try {
        await AsyncStorage.setItem('@MySuperStore:selectedLocation', loc);
        selectedLocation  = loc;
      } catch (error) {
        // Error saving data
      }
    }
  
    static getGpsOn() {
      return gpsOn;
    }
  
    static async setGpsOn(on) {
      try {
        await AsyncStorage.setItem('@MySuperStore:gpsOn', on);
        gpsOn  = on;
      } catch (error) {
        // Error saving data
      }
    }
  
    static getMapType() {
      return mapType;
    }
  
    static async setMapType(type) {
      try {
        await AsyncStorage.setItem('@MySuperStore:mapType', type);
        mapType  = type;
      } catch (error) {
        // Error saving data
      }
    }
  
    static getCurCoor() {
      return {lat: curLat, long: curLong};
    }
  
    static async setCurCoor(lat, long) {
      try {
        await AsyncStorage.setItem('@MySuperStore:curLat', curLat);
        curLat  = lat.toString();
      } catch (error) {
        // Error saving data
      }
      try {
        await AsyncStorage.setItem('@MySuperStore:curLong', curLong);
        curLong  = long.toString();
      } catch (error) {
        // Error saving data
      }
    }
  
  }
  
  module.exports = SettingsStorage;
  