Google Web Toolkit Local Storage

Learn how you can implement the local storage using Google web tool kit.

Local storage helps you to keep the data on client machine or end user machine but never use an important data on local storage because local storage is not a secure storage.

Creating an instance using Storage class and also checking whether the browser supports local storage or not using getLocalStorageIfSupported() method.

Storage stockStore = Storage.getLocalStorageIfSupported();

Insert the data using setItem() method , fetch data using getItem() method and clear the local storage data using clear() method.

stockStore.setItem(String key, String data);
stockStore.getItem(String key);

Set Item has two parameters, one is key and another one is data. Key is used to maintain the index and data is the parameter where we can save the string which is needed in other place.

Example :-
stockStore.setItem(“companyName”, “company”);

Get Item has only one parameter i.e., key , so enter the key to get a particular value.

stockStore.getItem(“userName”); // retrieve demo
stockStore.getItem(“companyName”); // retrieve company

Popular posts from this blog

Five More Indian Languages - Google Translate

Connect To JioFi Device Without Knowing The Passwords Using WPS