c# - UWP App SQLite Access database in Documents Library -


q: can't open sqlite database in documents folder:

app: universal windows (10) platform
development: c#, visual studio 2015
sqlite: using sqlite.net
targets: windows 10 desktop , windows 10 phone

deployment: visual studio or sideloaded (do not need store deployment)

using sqlite; using sqlite;    using sqlite.net;    using sqlite.net.async;    using sqlite.net.attributes 

i can:

open , read database included in project content:

using (sqlite.net.sqliteconnection conn = new sqlite.net.sqliteconnection (new sqlite.net.platform.winrt.sqliteplatformwinrt(), ".\\mydb.db3")) { //read queries } 

open/create , read/write database apps workspace:

string path = path.combine (windows.storage.applicationdata.current.localfolder.path,"another.db3");  using (sqlite.net.sqliteconnection conn = new sqlite.net.sqliteconnection (new sqlite.net.platform.winrt.sqliteplatformwinrt(), path)) { //crud } 
  • copy another.db3 documents
  • from there copy external memory device (sd card)

i can't

  • open database in documents or sd

i use filepicker choose db in documents or sd
use file.path property when attempting open database connection

windows.storage.storagefile file = await filepicker.picksinglefileasync();   string path = file.path; 

i following error message when attempt open connection:

exception thrown: 'sqlite.net.sqliteexception' in sqlite.net.dll
sqlite-getallvendors: not open database file: c:\users\me\documents\another.db3 (cannotopen)

have added sqlite .db , .db3 file associations.

      <extensions>         <uap:extension category="windows.filetypeassociation">           <uap:filetypeassociation name=".db">             <uap:displayname>sqlitedb</uap:displayname>             <uap:editflags openissafe="true" />             <uap:supportedfiletypes>               <uap:filetype>.db</uap:filetype>               <uap:filetype>.db3</uap:filetype>             </uap:supportedfiletypes>           </uap:filetypeassociation>         </uap:extension>       </extensions>     </application>   </applications> 

have added relevant capabilities

  <capabilities>     <capability name="internetclient" />     <uap:capability name="pictureslibrary" />     <uap:capability name="documentslibrary" />     <uap:capability name="videoslibrary" />     <uap:capability name="useraccountinformation" />     <uap:capability name="removablestorage" />     <devicecapability name="webcam" />     <devicecapability name="location" />   </capabilities> 

surely there way open sqlite database in documents or on memory stick form universal windows (10) app.
thx in advance

because sqlite opens database file directly rather going through file broker can see databases in app install , application data (the directories app has direct file permissions read , read/write respectively).

changing require update sqlite use streams file broker objects (storagefile , storagefolder) access locations have permissions granted via capabilities, pickers, etc.


Comments