locked
How to read and write to SQLite database file in documents library from windows store app?

    Question

  • Hi ,

    I want to create and write to a SQLite db file in user's documents library.

    Im able to do so only in the app's folder and app's installed location which I do not want. But unable to so so in the users documents library. 

    I have manually added the "Documents Library" capability in the packageappxmanifest.xml with .s3db file type association. But still when I run the app, I get SQLite exception saying- Cannot open the database in the location.

    Can anyone help me with this issue.

    Thanks 

    Tuesday, July 01, 2014 5:43 AM

Answers

  • One thing that makes Store apps different from desktop apps is that a Store app does not have access to the entire file system, and programmatic access even to the user's folders is limited. So your basic scenario is not supported.  One alternative might be to store the database on OneDrive.
    Thursday, July 03, 2014 6:09 PM

All replies

  • This does not seem like a good idea.  Why do you want to do this?

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Tuesday, July 01, 2014 12:39 PM
    Moderator
  • The documents folder is for the user's documents, not for app data.  Use the app data local or roaming folder for your database. See

    http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh967755.aspx and http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh464917.aspx

    Tuesday, July 01, 2014 6:21 PM
  • I have a desktop application which stores its db file in the user's C:\\Users\XXXX\ location.

    And I want my windows store app to read and write to this db file. Im unable to do this as I get an -SQLite exception saying- Cannot open the database in the location. 

    Thursday, July 03, 2014 4:10 AM
  • One thing that makes Store apps different from desktop apps is that a Store app does not have access to the entire file system, and programmatic access even to the user's folders is limited. So your basic scenario is not supported.  One alternative might be to store the database on OneDrive.
    Thursday, July 03, 2014 6:09 PM