Web SQL
Web SQL was introduced by Apple and is based on a free database SQLite. It will be discontinued very soon, and I intend to add it here only to show you how it could be used and how we can migrate to other advanced techniques without glitches. In the following code, we created a new shopping_cart_web_sql
project as a copy of the project from the Web Storage section and added WebSQLStorageManager
into the StorageManager
class:
abstract class StorageManager { factory StorageManager() { if (WebSQLStorageManager.supported) { return new WebSQLStorageManager(); } else if (WebStorageManager.supported) { return new WebStorageManager(); } else { return new CookieStorageManager(); } } Future<String> getItem(key); Future setItem(key, value); Future removeItem(key); }
First of all, check whether the web browser supports Web SQL and instantiate it if successful. You should specify the version and initial size of the database to be used. The...