Skip navigation
macbuc
Currently Being Moderated

Signle SQLite db to all app users

Mar 5, 2011 5:32 AM

Hi, I have to develop an AIR application that run in Win and Mac. The app is used by all the system users, I have to store a set of data in a db and I need that the data entered by a user are availabble to all users. If I create th db in the user data store folder this is not possible so how can I do that? I try to create the db in the app path and this work only if I manually set manually the folder privileges or if I develop a setup program thet set the folder access policy. There are a way t create data and save file in a folder availabble to all users?

 
Replies
  • Currently Being Moderated
    Mar 8, 2011 10:37 PM   in reply to macbuc

    Hello,

     

    When openning a database with SQLConnection, you can specify the location of the database as the first parameter of the open function. So if the location of the database can be accessed by all system users, these users can share the data in the database. Please try with the following code:

     

    var dbFile:File = new File("c:\\test.db");

    var conn:SQLConnection = new SQLConnection();

    conn.open(dbFile,SQLMode.CREATE);

     

    Any problem, please feel free to let us know.

     

    Thanks,

    Yang

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 9, 2011 10:35 AM   in reply to yang.liu

    How does this work if the apps are running concurrently? I can't imagine that it properly handles multiple writer connections from different processes does it? (if so I'll be happily surprised, but given how poorly it handles multple writer connections in the same process I'd be shocked)

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 9, 2011 7:23 PM   in reply to Brister1

    Multiple apps can not concurrently access a single SQLite database. SQLite will lock the whole database file when reading or writing data. This guarantees the safe access to SQLite in multiple-user environment.

     

    Thanks,

    Yang

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 11, 2011 1:58 AM   in reply to macbuc

    Could you try with the following code?

     

        var dbFolder:File = File.applicationStorageDirectory.resolvePath("db"); 
        dbFolder.createDirectory();
        var dbFile:File = dbFolder.resolvePath("test.db");
        var conn:SQLConnection = new SQLConnection();   
        conn.open(dbFile,SQLMode.CREATE);

     

    Hope this could help!

     
    |
    Mark as:
  • Chris Campbell
    8,532 posts
    May 4, 2010
    Currently Being Moderated
    Mar 14, 2011 10:44 AM   in reply to macbuc

    Unfortunately, on Windows Vista and 7 writing to the program files directory requires elevated privledges.  Is it possible you could prompt the user for a shared location?  Or, maybe go up to the root of the C: drive and create a new folder?

     

    Chris

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points