How to embed SQLite database to Air app?

Now I connect to a database file like this:
var dbFile:File = File.applicationStorageDirectory.resolvePath("myDB.db");
conn = new SQLConnection();
conn.openAsync(dbFile);
conn.addEventListener(SQLEvent.OPEN, openSuccess);
conn.addEventListener(SQLErrorEvent.ERROR, openFailure);
Tell me please, how do I embed the DB file to the application? I need to have the database inside a swf.

Here's info on encrypting a database in AIR:
Creating an encrypted database
Working with the encrypted local SQLite database
flash.data.SQLConnection
Chris

Similar Messages

  • How to connect to and communicate with an SQLite database in AIR/Flex

    Hey guys,
    I recently decided I would try programming a vocabulary-training program in AIR, so I could use it on Linux as well. I got stuck pretty soon. I am trying to connect to a local SQLite database and I obviously fail epically. Posting the source code of the application here:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
       <mx:Script>
          <![CDATA[  
               import flash.filesystem.File;
              import flash.data.*;
             import mx.controls.Alert; 
                      private var dbFile:File;
                   private var conn:SQLConnection;
                   // -- AUTO INIT FUNCTIONS --------------------------------------------------- /
                   private function init():void {
                        // Create a File Reference to the Included DB
                        dbFile = File.applicationDirectory.resolvePath( "../slovniky.db" );
                        // Create SQL Connection
                        conn = new SQLConnection();
                        // Event Listener that will tell us when the DB is opened
                        conn.addEventListener(SQLEvent.OPEN, openSuccess);
                        // Event Listener that will tell us if an error occurs
                        conn.addEventListener(SQLErrorEvent.ERROR, openFailure);
                   // -- EVENT HANDLERS -------------------------------------------------------- /
             private function starter() :void {
                  slovickoEn.enabled = true;
                  nazor.enabled = true;
                  odeslat.enabled = true;
                  zrusit.enabled = true;
                  start.enabled = false;
                  // Otevírám spojení s databází v asynchroním módu
                   conn.openAsync( dbFile );
             private function openSuccess( event:SQLEvent ):void {
                        // Pokud se spojení povede!
                        Alert.show("Spojení se zdařilo!");
               private function openFailure( event:SQLEvent ):void {
                        // Pokud spojení selže!
                        Alert.show("Spojení se nezdařilo!")
             private function kontrola() : void {
                  if (nazor.text != "") {
                       if (nazor.text == "Pes") {
                       Alert.show("Správně!");    
                       else {
                       Alert.show("Špatně!! " + "Napsané slovíčko bylo " + nazor.text);     
          ]]>   
       </mx:Script>
       <mx:VBox width="400" height="200"
                   horizontalCenter="0" verticalCenter="0" backgroundColor="#FFFFFF"
                   paddingBottom="20" paddingLeft="20" paddingRight="20" paddingTop="20"
       >
          <mx:HBox width="100%" verticalAlign="middle" horizontalAlign="center">
             <mx:Label text="Anglicky:"/>
             <mx:TextInput id="slovickoEn" editable="false" text="Dog" enabled="false"/>
          </mx:HBox>
          <mx:HBox width="100%" verticalAlign="middle" horizontalAlign="center">
             <mx:Label text="Česky:"/>
             <mx:TextInput id="nazor"  enter="kontrola()" enabled="false"/>
          </mx:HBox>
          <mx:HBox width="100%" horizontalAlign="center">
             <mx:Spacer width="50" height="10"/>
             <mx:Button id="odeslat" label="Odeslat" color="#0D8401" click="kontrola()" enabled="false"/>
             <mx:Button id="zrusit" label="Zrušit" color="#0D8401" enabled="false"/>
          </mx:HBox>
          <mx:HBox width="100%" horizontalAlign="center">
             <mx:Spacer width="50" height="10"/>
             <mx:Button id="start" label="Start" color="#0D8401" click="starter()" enabled="true"/>
          </mx:HBox>
       </mx:VBox>
    </mx:WindowedApplication>
    The Run of the program tells me this:
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
         at pes/starter()[C:\air\projects\pes\src\pes.mxml:45]
         at pes/__start_click()[C:\air\projects\pes\src\pes.mxml:93]
    I would appreciate any help or a how-to. I am an absolute beginner with some experience from HTML, CSS, PHP and rarely JS. What am I doing wrong? File attached for easier manipulation as well.
    Erthy

    Hi,
    Here is the complete example for the same with the code.Let me know if you have any issue with this.
    http://shardulbartwal.wordpress.com/2008/04/14/adobe-air-and-sqlite-connectivity/
    with Regards,
    Shardul Singh Bartwal

  • How to copy sqlite database from applicationDirectory to documentsDirectory

    I am having problems using the ‘File’ function in Adobe Flex to copy a sqlite database from the read only applicationDirectory to the users documentsDirectory.  When I use the code below the only thing that appears in the user documentsDirectory is a 1k to 4k file.  The actual file size of the database is around 350k.
    Am I not giving the file enough time to copy over?
    I am developing on a Mac but I think I remember duplicating the error on a PC as well.  This bug has been keeping me from launching my app for far too long.  Any ideas would be appreciated.
    Here is the code I am using:
    public function copyDB():void
              var dbFile:File = File.applicationDirectory.resolvePath("db/myDataStorage.db");
              var dbWorkedFile:File = File.documentsDirectory.resolvePath("myDataStorage.db");
              if(!dbWorkedFile.exists){
                        trace("db Does Not Exist");
                        dbFile.copyTo(dbWorkedFile);
              } else {
                        trace("db Exists");
                        //The database has already been installed.  Launch app.
              dbConn = new SQLConnection();
              dbConn.openAsync(dbWorkedFile);
    I got the above code from this Adobe Cookbook recipe:
    http://cookbooks.adobe.com/post_Include_existing_SQLite_database_in_an_AIR_applica-10483.h tml
    Thanks

    I got it working. 
    I tried the copyToAsync method and it did not work.  While testing the copyToAsync I found a path that brought me to the
    'preinitialize' phase of the application startup sequence. 
    I fixed it by calling my copyDB() function from the 'preinitialize' call in the windowedApplication tag like:
    preinitialize="copyDB()".
    I had been calling it from the applicationComplete phase of startup.  Now it seems so obvious.
    Thanks again for sending me down the path that finally fixed it.

  • How to use expansion files for AIR app (flash cs6) on Google Play Store

    I am currently working on an app that will undoubtedly end up bigger than the maximum size of 50 MB for the APK, and I have no clue how to add files to an expansion pack, how to load expansion pack, what files need to be in expansion pack, or even what an expansion pack does/how it works. If anyone can point me in the right direction, that would be great, I want to make an expansion pack now before I get even more files.

    Haven't had a need to do this for file size purposes but since we can now download and use SWFs with ABC, I just specify my external SWFs when I compile and once my app is run it downloads the SWFs (with a pretty preloader) before the user can do anything. I have my own servers so I believe that's all that Amazon Bucket is actually used for. That user didn't have their own web servers to serve up the SWF content from.
    Aside that, check the answer here. Google will turn any extra files uploaded for your app into OBB for you. You just upload the SWF:
    Create expansion file for AS3 android Air App Flash cs6 - Stack Overflow
    It also outlines if you need to upload multiple files then .zip them up and use an AS3 .zip library to extract the files.

  • How to (re) take fullscreen when AIR app is restored from dock/task bar?

    Porting an AS3 app to AIR -- learning AIR as I go.
    Switched to AIR because we need to minimize our app to taskbar/dock -- works nicely.
    But when I listen for Event.ACTIVATE and then try to NativeWindow.maximize(), it doesn't work.
    Found the bug thread with the workaround (http://forums.adobe.com/message/3251136), which is to listen to the display stage change and if the current window stage is NORMAL then to maximize.
    stage.nativeWindow.addEventListener(NativeWindowDisplayStateEvent.DISPLAY_STATE_CHANGE, onDisplayStateChange);
    public function onDisplayStateChange(evt:NativeWindowDisplayStateEvent):void
         if (evt.afterDisplayState == NativeWindowDisplayState.NORMAL)
         stageDetails();
    Is this still best option?
    Also, when I maximize() using the above technique on the Mac the menubar is still visible.  How to get back to fullscreen?
    Thanks!

    Alright, Superduper app on the backup drive allows me to launch SD, however, when I select the copy from drive (my backup) to copy to the copy to drive, the laptop HD, I find that the Laptop HD is grayed out.
    I dragged and dropped SD to the Laptop and then launched and received the same result, the Laptop HD is still grayed out.
    My SD says at the bottom of the window, Unregistered, but it was registered on my laptop before the OS install.
    So i am I right that I have to get my network working, then register SuperDuper again, then see if I can select the Laptop HD as the destination drive for moving the apps over to?

  • How do I create a local AIR app that loads a network resource that loads a network resource?

    Ok, when you think about it, what I'm trying to accomplish
    isn't that difficult, yet I'm running into security sandbox
    violations all over the place.
    Here's the scenario:
    - I have a network-enabled SWF that lives in a web server,
    that pulls external content via the network. That part works fine
    when you run it as itself.
    - THEN, I have an AIR application that is nothing but a
    "stub" that loads that network-enabled SWF from a web server, that
    in turn is supposed to pull the external content from the network.
    It seems easy: I don't want to have to bundle up that same
    main SWF as an AIR application as that would create two code bases
    to maintain should there be any future bug fixes. Count that
    against countless installs on both the web-version and the desktop
    version, and there's lots of variables. So I just wanted the AIR
    application to pull that single SWF off the server and have it do
    its work, independent of the AIR application.
    However, the problem I'm running into is:
    quote:
    SecurityError: Error #2142: Security sandbox violation: local
    SWF files cannot use the LoaderContext.securityDomain property.
    app:/buzztv_desktop_0.1.swf was attempting to load
    http://localhost/widget/widget.swf.
    at flash.display::Loader/_load()
    at flash.display::Loader/load()
    There was a previous instance of that same error that
    referenced Stage, but I solved that by wrapping the main function
    in an if (stage) {}, so this is the next error on the list. I have
    a feeling that if I've encountered these two errors already, there
    are more lined up behind them.
    So I tried something like
    quote:
    _loader.load(request, new LoaderContext(true, null,
    SecurityDomain.currentDomain));
    ...thinking that it might help, but it didn't.
    Is there a reasonable solution to this without changing the
    entire workflow of the project, or do I simply have to have the
    same main SWF as two code bases, one for the embeddable web
    version, and one for the desktop version (read: they are intended
    to do the same exact thing, no differing features, no desktop
    notifications, etc.)?
    Thanks in advance!

    Hi,
    I have simillary problem, please, did you find solution?
    Thx

  • How to connected mysql database to iphone app?

    I make application which must use mysql database because my application is related to other desktop application

    If the app uses the same db as on the user's computer, you should look into using iCloud to share and sync the data. Visit the iOS Dev Center for details.

  • HT1414 How to view SQlite database files in device backup

    when tryig to charge my relatively new iPhone via usb and laptop, I accidentally restored my iphone to my wifes iphone settings because it was her itune account.  All of my data was erased.  How can I view my text messages that were on my phone before I accidentally restored my iphone. I have tried using SQL database programs but they are confusing. I am not comuter savy, so if anyone can offer "idiot proof" step by step instructions I would be very appreciateive. They are both iPhone 4.   Thank you so much.

    is your computer a pc?

  • How to encrypt sqllite Database

    Hello,
    Can anyone please guide me how to encrypt sqlite database in flex?
    Thanks.

    You can try this example: http://www.adobe.com/devnet/air/flex/quickstart/articles/encrypted_database.html
    I'm  not sure if it also encrypts the actual data, though.

  • Phonegap, iPhone and SQLite database

    Hi there,
    I'm trying to develop my first iPhone app using Phonegap and SQLite database. My app is simple but don't know how to get started. My app has 2 dropdown list. When the user selects one of them the other dropdown list will reset.  Then user will click on Submit button and I want to search the database and display the result.
    I've never used the SQLite database and I would like to know in which folder should I keep the database file. The database file is small and will be stored on the device. The database is already populated. User will not add,edit or delete data but only search based on what value was selected using dropdown list.
    Can someone tell me how to do this using JavaScript.
    Thanks,
    Joe Green

    PhoneGap is something that cross-platform developers use to avoid the native frameworks. The people on this forum are more familiar with the native frameworks. You would have to find a PhoneGap forum to ask about that product.

  • Embedding swf files in AIR app for ios

    Hi,
    After going through a lot of articles already available, I found answers with varying views on the following questions:-
    1) Can we embed swf files using the embed tag in air app for ios, with symbols exported ?
    Something like [Embed(source="someSWF",symbol="exportedSymbol")]
    and also something like [Embed(source="someSWF")].
    From what I understand, one can't embed swf's with actionscript byte code in them. So exporting symbols actually creates class linkages which leads to creation of abc. But I'm unsure on this because some sources say otherwise.
    2) Can we embed swf files using embed tag in air app for ios, without symbols exported ?
    Something like [Embed(source="someSWF")]
    and also something like [Embed(source="someSWF" mimeType = "application/octet-stream")]
    I read somewhere else, that you can actually embed symbols separately by providing symbol tag in embed tag but not entire swf (which leads to uncompiled actionscript error) but not sure about this as this is contradictory to finding #1.
    3) If #2 is possible, then do embedding two different swfs with same symbol names would cause a conflict and result in #3747 error ?
    Please note I am not asking about the Loader class here but using the Embed keyword for embedding swfs.
    Also do the results differ with AIRSDK 3.8 and 3.9 and using different swf-version in compiler flags ?
    In our application we started getting error #3747 in class creation of one of the embedded swfs (like new EmbeddedClass()) when we changed from swf-version 17 to 21 using AIRSDK 3.8. So was this error not there earlier or it was there but swf-version was suppressing it ?
    Any help is much appreciated.
    Thanks!

    I am fairly sure that the answer to your questions is: “no”.
    For embed to work the AIR app would have to be working in interpreter mode, and that can work for local testing, but can’t work for submitting apps. An easy change for you to do would be to use SWCs instead of Embed. Other than that you’re looking at Loader, but also a tricky command line build of the app.

  • Mobile app to desktop air app

    How do I convert my mobile air app to a desktop air app.  I basically just want the app to look just like the emulator version but maybe with a 1024x768 view instead (tablet sized).

    When you build the release build of the application, you can choose "AIR for desktop" and the app looks exactly like in the emulator.
    Otherwise you have to port some of your application components to an AIR project (if you want the full AIR desktop functionality).

  • Simple Air App

    How can i create a simple AIR app very simple just some basic animations and to be transparent on the desktop?

    No. Since there is no radio tuner in the iPhone, it's not possible to do so. There used to be, and may still be, FM radio recievers available that connect to the dock connector.

  • How to determine the connection string to a SQLite database, in C# code

    Hello. I'm trying to figure out how to specify the connection string to a SQLite database, I would like to access using the following code:
    string connectionString = null;
    SqlConnection connection;
    SqlCommand command;
    SqlDataAdapter adapter = new SqlDataAdapter();
    DataSet ds1 = new DataSet();
    string sql = "SELECT DataName, Data, Id, UserId, DateLastUpdated FROM MainTable";
    connectionString = "Data Source=C:\\SQLITEDATABASES\\SQLITEDB1.sqlite;Version=3;";
    connection = new SqlConnection(connectionString);
    try
    connection.Open();
    command = new SqlCommand(sql, connection);
    catch
    The value I assigned to the variable connectionString, in the code above, I obtained somewhere from the Internet. It does not work. I'm using Visual Studio 2013, against the file sqlite-netFx451-setup-bundle-x86-2013-1.0.96.0.exe, which
    I installed, and got from
    here.
    My application's App.config file looks as follows:
    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
    <configSections>
    </configSections>
    <connectionStrings>
    <add name="DC_Password_Saver.Properties.Settings.DC_Password_SaverConnectionString" connectionString="data source=&quot;C:\Users\patmo_000\Documents\Visual Studio 2013\Projects\DC Password Saver\DC Password Saver\DC Password Saver.db&quot;" providerName="System.Data.SQLite.EF6"/>
    </connectionStrings>
    <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1"/>
    </startup>
    </configuration>
    I tried to use the value assigned to connectionString in the XML settings above, replacing single backslash characters with double backslash characters, because the Visual Studio editor flagged them as unrecognizable, and wound up with the
    following.
    SqlDataAdapter adapter = new SqlDataAdapter();
    DataSet ds1 = new DataSet();
    string sql = "SELECT DataName, Data, Id, UserId, DateLastUpdated FROM MainTable";
    connectionString = "data source=&quot;C:\\Users\\patmo_000\\Documents\\Visual Studio 2013\\Projects\\DC Password Saver\\DC Password Saver\\DC Password Saver.db&quot;";
    connection = new SqlConnection(connectionString);
    The above code however does not work either. So again, does anyone know how I can specify in C# code, a connection string to access my SQLite database? Thanks in advance for your reply.

    What does SQLite connection strings has to do with WPF?
    You will find some valid connection strings here:
    https://www.connectionstrings.com/sqlite/
    But you cannot use the SqlConnection class to connect to a SQLite database. You will need to download and add a reference to the System.Data.SQLite library and then use the SQLiteConnection class:
    connection = new System.Data.SQLite.SQLiteConnection(connectionString);
    try
    connection.Open();
    command = new System.Data.SQLite.SQLiteCommand(sql, connection);
    catch
    Please refer to the following article for more information and an example of how to connect and read and write data from an SQLite database using C#:
    http://blog.tigrangasparian.com/2012/02/09/getting-started-with-sqlite-in-c-part-one/.
    There is contains a link where you can download the required assemblies.
    Hope that helps.
    Please remember to mark helpful posts as answer to close your threads and then start a new thread in an approproate forum if you have a new question.

  • How to embed and play mp4 video in HTML AIR application?

    Adobe Air HTML / JS application compiled from SDK command line.  I am not using flash pro or flash builder to create the application.
    I was using dreamweaver but the dw air plugin seems to have stopped being developed so I switched to using the command line tools.
    I am creating desktop air application that has embedded mp3 audio and also I want to embed mp4 video.
    Using jQuery and the AIR js plugin I am able to play audio via buttons hooked up via jQuery and the AIR js plugin from the SDK.
    What I am doing is creating proofs for clients in AIR and sending link to the client to download the application.  I embed the media because I do not want to place them on a website where it could possibly be seen by non-clients and get picked up in the SE's.
    I am finding it hard to understand the AIR process for playing video.  I read that it is the same procedure as audio but it does not work.
    If it was hosted on youtube or somewhere embedding the web player would be simple, just copy paste some code and it works.  When actually embedding the video say mp4, f4v, mov, wmv or similar file formats I can't get AIR to play the video.  Audio, not a problem it works great.
    I would like to do the following with video.
    Embed the actual file in the AIR app.  I can do this, it gets embedded.
    Play, pause and stop the video - Can't get this to work
    Get the current stop point and be able to start the video by sending a start point - This is all working with audio I just want to do it with video.
    I have searched the forums, the search engines, youtube and read through the documentation on Air but the video does not work at all.
    I need code samples and direction on how to make an embedded video play inside of a desktop air application using the HTML / JS air model. I am using the command line tools to create the air package and test the air app.
    Please help if you have figured this out.
    Thank you.
    Not sure if this matters but I am using Windows 7 Pro 64bit as my development machine.

    In addition I also can not get html5 video to play in the adobe air app.  Would this issue be tied to the above?

Maybe you are looking for