There are many ways to offline storage in hybrid/ionic app:
1. Cookies
2. Offline Storage
3. Sqlite Database
1. Cookies : Consider this method if size of data is very less. Mostly cookies are used only for login purposes.
2. Offline Storage: This method used key/value pair to store data.
Following code will store data in memory of user's webview/browser:
if(window.localStorage !='undefined'){
localStorage.setItem("user-name", "Jason sta");
}
To retrieve above saved data we have to right below code:
var userName = localStorage.getItem("user-name");
3. Sqlite Database:
There are two ways we can create sqlite database in mobile browser/webview.
A. Using Javascript/html5 code
B. Using Java code:
After creating database we have to copy the database into source code of mobile app before creating apk/ipa file.
1. Cookies
2. Offline Storage
3. Sqlite Database
1. Cookies : Consider this method if size of data is very less. Mostly cookies are used only for login purposes.
2. Offline Storage: This method used key/value pair to store data.
Following code will store data in memory of user's webview/browser:
if(window.localStorage !='undefined'){
localStorage.setItem("user-name", "Jason sta");
}
To retrieve above saved data we have to right below code:
var userName = localStorage.getItem("user-name");
3. Sqlite Database:
There are two ways we can create sqlite database in mobile browser/webview.
A. Using Javascript/html5 code
B. Using Java code:
After creating database we have to copy the database into source code of mobile app before creating apk/ipa file.
No comments:
Post a Comment