Example usage for com.google.gwt.corp.localstorage LocalStorage setItem

List of usage examples for com.google.gwt.corp.localstorage LocalStorage setItem

Introduction

In this page you can find the example usage for com.google.gwt.corp.localstorage LocalStorage setItem.

Prototype

public static void setItem(String key, String value) throws IOException 

Source Link

Usage

From source file:com.badlogic.gdx.backends.gwt.GwtPreferences.java

License:Apache License

@Override
public void flush() {
    try {//from  ww  w . j  a v a  2  s.  co  m
        // remove all old values
        for (int i = 0; i < LocalStorage.length(); i++) {
            String key = LocalStorage.key(i);
            if (key.startsWith(prefix))
                LocalStorage.removeItem(key);
        }

        // push new values to LocalStorage
        for (String key : values.keys()) {
            String storageKey = toStorageKey(key, values.get(key));
            String storageValue = "" + values.get(key).toString();
            LocalStorage.setItem(storageKey, storageValue);
        }

    } catch (Exception e) {
        throw new GdxRuntimeException("Couldn't flush preferences");
    }
}