c# - How to get Sqlite Data after installing UWP application? -


i developing 1 universal windows platform application.in using sqlite local data base. when side loading application , installing able sqlite db structure not getting data. how can sqlite data base along data after installing side loaded application?

below code using creating sqlite.

           if (!file.exists(path.combine(applicationdata.current.localfolder.path, "testdb.sqlite")))           {             var sqlpath = path.combine(applicationdata.current.localfolder.path, " testdb.sqlite");             using (sqliteconnection conn = new sqliteconnection(new sqliteplatformwinrt(), sqlpath))             {                 conn.createtable<test_tablename >();             }           } 

as per 1 of suggestion have modified sqlite file storage location below

            package currentpackage = package.current;              storagefolder appstoragelocation = currentpackage.installedlocation;              if (!file.exists(path.combine(appstoragelocation.path, "testdb.sqlite")))             {                 // creates tables while creating database                 var sqlpath = path.combine(appstoragelocation.path, "testdb.sqlite");                  using (sqliteconnection conn = new sqliteconnection(new sqliteplatformwinrt(), sqlpath))                 {                     conn.createtable<test_tablename >();                 }           } 

but getting below exception while creating sqlite file using package.current.installedlocation.path

enter image description here

because of using package.current.installedlocation.path location unable create sqlite db.

how can resolve issue.am need other modifications?

if want sqlite data base along data after installing side loaded application, should able store file in package.installedlocation.

since installed location read should able copy testdb.sqlite file assets folder in project manually.

make sure sqlite file marked content , copied output directory. otherwise won't placed in appxpackage , available @ runtime.

on first time launched app, can sqlite file package.installedlocation can copy localfolder. can add data , deleted data in localfolder.

for example:

storagefile file = await storagefile.getfilefromapplicationuriasync(new uri("ms-appx:///assets/testdb.sqlite")); windows.storage.storagefolder localfolder = windows.storage.applicationdata.current.localfolder; await file.copyasync(localfolder); 

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -