· 7 years ago · Sep 10, 2018, 12:06 PM
1Trying to load SQLite database once and persist across views in mobile Flex app
2package com.myDomain.db
3{
4import flash.data.SQLConnection;
5import flash.data.SQLResult;
6import flash.data.SQLStatement;
7import flash.display.Sprite;
8import flash.events.SQLErrorEvent;
9import flash.events.SQLEvent;
10import flash.filesystem.File;
11
12public class dbOperations
13{
14 public var sqlConnection:SQLConnection;
15 public var stmt:SQLStatement = new SQLStatement();
16 private var isLoaded:Boolean = false;
17
18
19 public function OpenDB():void
20 {
21
22 if(!isLoaded){
23
24 isLoaded = true
25
26 sqlConnection = new SQLConnection();
27 sqlConnection.open(File.applicationDirectory.resolvePath("myFile.db"));
28 stmt.sqlConnection = sqlConnection;
29 stmt.text = "CREATE TABLE IF NOT EXISTS tblDefault(DefaultID integer primary key, Field1 text, Field2 numeric)";
30 stmt.execute();
31 }
32 }
33}