src/sqlite.android.js
function Database(dbname, options, callback) {
	if (!this instanceof Database) { // jshint ignore:line
		//noinspection JSValidateTypes
		return new Database(dbname, options, callback);
	}
	this._isOpen = false;
	this._resultType = Database.RESULTSASARRAY;
	this._valuesType = Database.VALUESARENATIVE;


	if (typeof options === 'function') {
		callback = options;
		//noinspection JSUnusedAssignment
		options = {};
	} else {
		//noinspection JSUnusedAssignment
		options = options || {};
	}

    //noinspection JSUnresolvedVariable
    if (options && options.multithreading && typeof global.Worker === 'function') {
	       // We don't want this passed into the worker; to try and start another worker (which would fail).
	        delete options.multithreading;
	        if (!Database.HAS_COMMERCIAL) {
	            throw new Error("Commercial only feature; see http://nativescript.tools/product/10");
            }
            return new Database._multiSQL(dbname, options, callback);
    }


	// Check to see if it has a path, or if it is a relative dbname
	// dbname = "" - Temporary Database
	// dbname = ":memory:" = memory database
	if (dbname !== "" && dbname !== ":memory:") {
		//var pkgName = appModule.android.context.getPackageName();
		//noinspection JSUnresolvedFunction
		dbname = _getContext().getDatabasePath(dbname).getAbsolutePath().toString();
		let path = dbname.substr(0, dbname.lastIndexOf('/') + 1);

		// Create "databases" folder if it is missing.  This causes issues on Emulators if it is missing
		// So we create it if it is missing

		try {
            //noinspection JSUnresolvedFunction,JSUnresolvedVariable
            let javaFile = new java.io.File(path);
			if (!javaFile.exists()) {
				//noinspection JSUnresolvedFunction
				javaFile.mkdirs();
				//noinspection JSUnresolvedFunction
				javaFile.setReadable(true);
				//noinspection JSUnresolvedFunction
				javaFile.setWritable(true);
			}
		}
		catch (err) {
			console.info("SQLITE.CONSTRUCTOR - Creating DB Folder Error", err);
		}
	}
	const self = this;

	return new Promise(function (resolve, reject) {
		try {
			let flags = 0;
			if (typeof options.androidFlags !== 'undefined') {
				flags = options.androidFlags;
			}
			self._db = self._openDatabase(dbname, flags, options, _getContext());
		} catch (err) {
			console.error("SQLITE.CONSTRUCTOR -  Open DB Error", err);
			if (callback) {
				callback(err, null);
			}
			reject(err);
			return;
		}

		self._isOpen = true;

		let doneCnt = _DatabasePluginInits.length, doneHandled = 0;
		const done = function (err) {
			if (err) {
				doneHandled = doneCnt;  // We don't want any more triggers after this
				if (callback) {
					callback(err, null);
				}
				reject(err);
				return;
			}
			doneHandled++;
			if (doneHandled === doneCnt) {
				if (callback) {
					callback(null, self);
				}
				resolve(self);
			}
		};

		if (doneCnt) {
			try {
				for (let i = 0; i < doneCnt; i++) {
					_DatabasePluginInits[i].call(self, options, done);
				}
			}
			catch (err) {
				done(err);
			}
		} else {
			if (callback) {
				callback(null, self);
			}
			resolve(self);
		}

	});
}
function Database(dbname, options, callback) {
	if (!this instanceof Database) { // jshint ignore:line
		//noinspection JSValidateTypes
		return new Database(dbname, options, callback);
	}
	this._isOpen = false;
	this._resultType = Database.RESULTSASARRAY;
	this._valuesType = Database.VALUESARENATIVE;


	if (typeof options === 'function') {
		callback = options;
		//noinspection JSUnusedAssignment
		options = {};
	} else {
		//noinspection JSUnusedAssignment
		options = options || {};
	}

    //noinspection JSUnresolvedVariable
    if (options && options.multithreading && typeof global.Worker === 'function') {
	       // We don't want this passed into the worker; to try and start another worker (which would fail).
	        delete options.multithreading;
	        if (!Database.HAS_COMMERCIAL) {
	            throw new Error("Commercial only feature; see http://nativescript.tools/product/10");
            }
            return new Database._multiSQL(dbname, options, callback);
    }


	// Check to see if it has a path, or if it is a relative dbname
	// dbname = "" - Temporary Database
	// dbname = ":memory:" = memory database
	if (dbname !== "" && dbname !== ":memory:") {
		//var pkgName = appModule.android.context.getPackageName();
		//noinspection JSUnresolvedFunction
		dbname = _getContext().getDatabasePath(dbname).getAbsolutePath().toString();
		let path = dbname.substr(0, dbname.lastIndexOf('/') + 1);

		// Create "databases" folder if it is missing.  This causes issues on Emulators if it is missing
		// So we create it if it is missing

		try {
            //noinspection JSUnresolvedFunction,JSUnresolvedVariable
            let javaFile = new java.io.File(path);
			if (!javaFile.exists()) {
				//noinspection JSUnresolvedFunction
				javaFile.mkdirs();
				//noinspection JSUnresolvedFunction
				javaFile.setReadable(true);
				//noinspection JSUnresolvedFunction
				javaFile.setWritable(true);
			}
		}
		catch (err) {
			console.info("SQLITE.CONSTRUCTOR - Creating DB Folder Error", err);
		}
	}
	const self = this;

	return new Promise(function (resolve, reject) {
		try {
			let flags = 0;
			if (typeof options.androidFlags !== 'undefined') {
				flags = options.androidFlags;
			}
			self._db = self._openDatabase(dbname, flags, options, _getContext());
		} catch (err) {
			console.error("SQLITE.CONSTRUCTOR -  Open DB Error", err);
			if (callback) {
				callback(err, null);
			}
			reject(err);
			return;
		}

		self._isOpen = true;

		let doneCnt = _DatabasePluginInits.length, doneHandled = 0;
		const done = function (err) {
			if (err) {
				doneHandled = doneCnt;  // We don't want any more triggers after this
				if (callback) {
					callback(err, null);
				}
				reject(err);
				return;
			}
			doneHandled++;
			if (doneHandled === doneCnt) {
				if (callback) {
					callback(null, self);
				}
				resolve(self);
			}
		};

		if (doneCnt) {
			try {
				for (let i = 0; i < doneCnt; i++) {
					_DatabasePluginInits[i].call(self, options, done);
				}
			}
			catch (err) {
				done(err);
			}
		} else {
			if (callback) {
				callback(null, self);
			}
			resolve(self);
		}

	});
}
*
Database Constructor
@param dbname - Database Name
@param callback - Callback when Done
@param options
@returns {Promise} object
@constructor