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

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

Introduction

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

Prototype

public static void removeItem(String key) throws IOException 

Source Link

Usage

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

License:Apache License

@Override
public void flush() {
    try {//from  w w 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");
    }
}