anaylor01 Posted January 6, 2014 Share Posted January 6, 2014 I am writing an app that needs to get the current location and store it in a database and then calculate the distance between the first location that was saved to the database and the current location. It will also need to use the phones system clock. Can this be done using HTML5? Quote Link to comment Share on other sites More sharing options...
P.Uri.Tanner Posted January 6, 2014 Share Posted January 6, 2014 depends. HTML 5 is a composition of front end technology. If you want to create persistency between clients and sessions safely you need some server to store data. For the frontend it looks a bit like this in javascript:// store Item in browserlocalStorage.setItem("banana", "tasty!")// return value from browservar storedItem = localStorage.getItem("banana")Here are more details: http://diveintohtml5.info/storage.html Quote Link to comment Share on other sites More sharing options...
anaylor01 Posted January 6, 2014 Author Share Posted January 6, 2014 So you can't code HTML5 to store data in a sqllite database? That doesn't make much since. If the user doesen't have internet access it wouldn't work. Quote Link to comment Share on other sites More sharing options...
Autarc Posted January 6, 2014 Share Posted January 6, 2014 Like puritanner mentioned, it depends on what you like to achieve. Accesing the system clock for retrieving the current time can be done via the browser implementation of the Date Object. Storing information for offline usage can be done via AppCache in combination with a web storage solution. Besides Local- or SessionStorage, you could also leverage a real database in form of IndexedDB with proper transactions. A former SQL based solution is deprecated and won't be supported by most clients. If you like to keep the data synchronized beween multiple systems, you will need an additional server. This one won't be restrained by the different browsers and therefore be able to use SQL approaches as well. Quote Link to comment Share on other sites More sharing options...
anaylor01 Posted January 6, 2014 Author Share Posted January 6, 2014 So are you saying I can use a local DB and not have to use a web based storage? That is my question. I only want to use a local database. Quote Link to comment Share on other sites More sharing options...
Chris Posted January 7, 2014 Share Posted January 7, 2014 Just to note: If a user has no internet access, he won't be able to start your app at all Stuff like localstorage or indexedDB are only useful when you have partial network disruptions and need to store data while the app is offline. When you come back online, you can re-sync with the server. Storing data in a local DB or localstorage is unsafe. If the user decides to delete his browser cookies for whatever reason, all your data gets purged. Quote Link to comment Share on other sites More sharing options...
Gio Posted January 8, 2014 Share Posted January 8, 2014 Also support for IndexedDB isn't great at the moment, and is completely missing in some browsers, most notably Safari (even the desktop version of it). WebSQL is more widely supported at present, but it's been deprecated and eventually people will have to move to IndexedDB. Right now we're in a transition period, and if you want to support all browsers you have to support both types of technology. Besides IndexedDB is asynchronous and far from reliable: for example, if you initiate a query to store data it may take some time (depending on the amount of data) and it could be that user closes the browser before it's complete, in which case it's never going to be completed. The only web API that I know of that you can rely on to store data locally, is the FileSystem API (in persistent storage mode) which, unfortunately, is only supported by Chrome. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.