Search code examples
actionscript-3apache-flexflash-builder

Flex database getting overwritten


I am maintaining an existing flex desktop application which is using SQLite3 database. I am very new to Flex programming. The database originally has some test values which I changed by deleting the existing table importing the new data with same table name. Now once I run the application, I still see old data, and on checking the database table find test values back there and new values gone. I checked the code for any insert or import statement but could not locate one. Does any one faced similar issue? Is it because database cacheing, if yes then how to clear this cache? Any hint on what could be the reason behind this weird issue?


Solution

  • Flex creates a location to save data locally in machine. In my machine the path is under my userid AppData\Roaming\ProjectName\Local Store\Database\dbname.db

    And my code responsible is following (Line 9, dbWorkFile variable):

        public function SQLCon(strQuery:String):SQLResult
        {
            try
            {               
                var dbStatement:SQLStatement = new SQLStatement();
                var dbFile:File = File.applicationDirectory.resolvePath("DataBase/question.db"); //file in the compiled folder
                var dbWorkFile:File = File.applicationStorageDirectory.resolvePath("DataBase/question.db");//Location of roaming database
                if(!dbWorkFile.exists){
                    dbFile.copyTo(dbWorkFile);
                }
                conn = new SQLConnection(); 
                conn.open(dbWorkFile);   
                ....
    

    Leaving this answer for benefit of someone who faces similar ghost issue :)