Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

Couldn't copy SQLite DB to iOS folder

$
0
0

Hello everyone.
I'm trying to execute data from some sqlite DB, but i can't since it doesn't copying to app's local folder. Looks like program creates new one, empty, so i get an error that "no such table found".

There is my code:
`global::Xamarin.Forms.Forms.Init ();

        string docFolder = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
        string libFolder = Path.Combine(docFolder, "..", "Library");

        if (!Directory.Exists(libFolder))
        {
            Directory.CreateDirectory(libFolder);
        }

        string dbPath = Path.Combine(libFolder, "KDLife_mobileDB.db3");

        if (!File.Exists(dbPath))
        {
            var existingDb = NSBundle.MainBundle.PathForResource("KDLife_mobileDB", "db3");
            File.Copy(existingDb, dbPath);
        }

        LoadApplication (new KDLife_mobile.App ());

`

Just wondering what is wrong with it.
I copied normal DB to app's local path and everything worked fine.


Viewing all articles
Browse latest Browse all 91519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>