localForage using WebSQL web IndexedDB available - javascript

I am building a Cordova app with the Ionic Framework. I am using angular-localForage as the local database for the app's persistent storage.
While developing, I am testing my app using Google Chrome 45.0.2454.85 m on Windows 10. angular-localForage is at version 1.2.3 and localForage is version 1.2.4.
I can set and retrieve data no problem. To set data I am using:
$localForage.setItem(myKey, myData).then(myCallbackFunction);
According to the docs, localForage should use IndexedDB if it's available and fall back to WebSQL for browsers where it is not available. I can see from looking at Resources in Chrome Developer tools that it is storing my data in WebSQL.
If I put this code in my controller I get a message saying IndexedDB is available:
if (!window.indexedDB) {
window.alert("Your browser doesn't support a stable version of IndexedDB. Such and such feature will not be available.");
} else {
window.alert("IndexedDB available.");
}
My question is, why is it using WebSQL in Chrome when I have IndexedDB available?

The problem is actually quite sneaky.
TLDR; Apple's UIWebView doesn't support indexedDB. Turn off Chrome's iOS emulator to see indexedDB working.
What's happening is that I'm assuming you're emulating an iPhone with Chrome dev tools. Well, this spoofing is actually really effective because localForage will now emit an error if you configured it to exclusively use indexedDB.
If you want to have a moment of profound ennui and see indexedDB in action... turn off emulation so that you're using Chrome's own user-agent. It'll work then.
Source: I had to deal with this nonsense myself. It was a really bad developer experience. HAH.

My guess is that websql is taken as first choice since it exists longer than the indexeddb api and chrome was pushing websql earlier than indexeddb. Since chrome still supports websql it takes websql before indexeddb.

Related

access web serial api in android chrome browser

using web serial API in windows, mac os, and Linux chrome browser I can receive and send data. but in the android chrome browser, I am not able to send or receive data from a serial device.
so which API is used to read and write data to serial devices in the android chrome browser.
also, there is a polyfill serial API for android chrome but is showing an error shown in the image.
The team that built the implementation of the Web Serial API in Chromium also wrote a polyfill library which uses WebUSB to support platforms which don't provide built-in serial drivers: https://github.com/google/web-serial-polyfill
It looks like you are already trying to use this library. Can you file an issue on the library's GitHub project so the team can look at the error you're seeing?
Note, it seems like there are some Android devices which have USB serial drivers that end up blocking WebUSB from claiming interfaces even though the platform doesn't let apps actually use them. https://crbug.com/1099521 is tracking a workaround for that.

Will my apps lose localStorage data if Crosswalk updates it's internal browser?

Recently I adopted cordova's crosswalk plugin to ensure a uniform and performant HTML5 environment across android devices. Everything was working fine until I deploy the application. That's when I noticed that all existing settings from the native browser, which was being used by the cordova webview were gone! Our localStorage was now in a different browser - the chromium browser which is served by crosswalk project.
Now I'm asking myself what will happen if the crosswalk project updates it's internal browser to a new chromium browser version? Will I lose the localStorage data once again?
Here are some references that I had look at while researching into the subject:
Crosswalk storage limits
Scope of sessionStorage and localStorage
Where the sessionStorage and localStorage stored?
Probably yes, you will lose the data. Also updating the device SO can cause the loss of data. I had the same problem. You should consider to use sqlite database to persist permanently your data.
The issue that was concerning this subject was closed last week. "Not able to migrate the existing webview data (localstorage/websql) to crosswalk"
Check it out here: https://crosswalk-project.org/jira/browse/XWALK-7368

Web SQL not working from local file system, how can I run without any server?

After updated the chrome browser the WebSQL not working from local files, but it is working from server like IIS,Xampp or other. How can I Access the webSQL without using server.
This seems to be a bug.
See Chromium bug report
It is fixed in currently available Beta Chrome version ( 52.0.2743.60 beta-m ).
You can also use Safari browser, which have a pretty safe implementation of WebSql API.
there is no way as latest updates of chrome and opera have put a restriction on code accessing client-side websql database to be accessible from server hosted code only

Cross Browser Platform Data Storage

I am creating a Cross browser Platform Web Application (HTML, JS, CSS), However I require a strong database storage that I can query on the client using JS. Web SQL/SQLite seems to be the best way to go BUT there is no support for it in IE. Does anyone know of any other querable client storage out there. or a working implementation of embedding SQLite "like" functions into the browser.
Thanks
The Web Storage API is available in all major browsers including mobile and desktop. I haven't used it before, but from my research I can tell that it doesn't use SQL queries. It seems to be the best option, even so I would recommend still using a fallback for browser that won't support the API (for example anything before IE8).
Hope this works out for you!

Which version of firefox will support Web SQL?

I'm developing an app that needs offline storage SQL.
I try:
if (window.openDatabase) {
window.db = window.openDatabase("app", "", "my app db name", 1024*1024);
}
this works great on Chrome but doesn't work on my Firefox 3.6
What version of firefox will support openDatabase?
Mozilla have said they will never implement it according to this thread:
HTML5 IndexedDB, Web SQL Database and browser wars
I believe FF is working towards implementing IndexedDB instead.
If you're interested to know what browsers support what you can check out Caniuse. In particular about local storage see this
Edit: Oops! I didn't realize this was a year old.
Default location for WebSQL DB in case of Firefox:
C:\Users\username\AppData\Roaming\Mozilla\Firefox\Profiles\mlolddya.default\databases\
For Chrome:
C:\Users\username\AppData\Local\Google\Chrome\User Data\Default\databases\
for safari:
C:\Users\username\AppData\Local\Apple Computer\Safari\Databases\
new version of FF are not using WebSQL they are moved to IndexedDB.which is good
no need to give support for two different db if you dont want to give support for Safari

Categories

Resources