Coleim opened a new issue, #1787: URL: https://github.com/apache/cordova-android/issues/1787
# Bug Report ## Problem When using window.openDatabase, it works when I first lunch the app, but when I quit the app (swipe out) and relaunch it, the window.openDatabase become undefined. I am migrating an older app to a newer cordova version, and I would need to keep using websql. ### What is expected to happen? window.openDatabase to be defined ### What does actually happen? window.openDatabase is undefined ## Information I created a sample app here: https://github.com/Coleim/window.openDatabase.issue You can reproduce it by running the app, killing it and run it again. If you check the logs you will see on first launch: Pre-Cordova - Is window.openDatabase available? Yes Device Ready db successfully opened or created Query completed: {} and then on restart: Pre-Cordova - Is window.openDatabase available? No index.html:114 Device Ready index.html:118 Uncaught ReferenceError: openDatabase is not defined at Channel.<anonymous> (index.html:118:22) at Channel.fire (cordova.js:872:23) at cordova.js:232:49 If you go on your phone parameter, then application and you remove the data, it will be available again, until you kill your app again. ### Command or Code cordova create MyApp cd MyApp cordova platform add android >> Add the following code on index.js ``` /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ // Wait for the deviceready event before using any of Cordova's device APIs. // See https://cordova.apache.org/docs/en/latest/cordova/events/events.html#deviceready document.addEventListener('deviceready', onDeviceReady, false); function onDeviceReady() { // Cordova is now initialized. Have fun! console.log('Running cordova-' + cordova.platformId + '@' + cordova.version); document.getElementById('deviceready').classList.add('ready'); console.log('Device Ready'); console.log('Post-deviceready - Is window.openDatabase available?', typeof window.openDatabase === 'function' ? 'Yes' : 'No'); if (typeof window.openDatabase === 'function') { var db = window.openDatabase('testdb', '1.0', 'Test DB', 2 * 1024 * 1024); console.log('Database opened'); db.transaction(function(tx) { tx.executeSql('CREATE TABLE IF NOT EXISTS test (id INTEGER PRIMARY KEY, data TEXT)', [], function() { console.log('Table created'); tx.executeSql('INSERT INTO test (data) VALUES (?)', ['test_data'], function(tx, res) { console.log('Data inserted, ID:', res.insertId); }); }); }, function(error) { console.error('Transaction error:', error.message); }, function() { console.log('Transaction complete'); }); } else { console.error('WebSQL unavailable'); } } ``` Then: cordova run android or generate the apk and install it on your phone ### Environment, Platform, Device I tested on Android HUAWEI VOG-L29 Android 10 API 29 and on another Android device as well ### Version information > cordova -v 12.0.0 (cordova-lib@12.0.1) > cordova platform ls Installed platforms: android 13.0.0 Using vs code and chrome://inspect/#devices to inspect the device. ## Checklist - [X] I searched for existing GitHub issues - [X] I updated all Cordova tooling to most recent version - [X] I included all the necessary information above I even tried to ask Grok in case it found a clue ... but no success: https://x.com/i/grok/share/sAqgCoP5ln2Foxhw5mXbWjDTS -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org For additional commands, e-mail: issues-h...@cordova.apache.org