Example #1
0
        public global::SQLite.Net.SQLiteConnection GetConnection()
        {
            var    sqliteFilename = "M2ESQLite.db3";
            string documentsPath  = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
            // Documents folder
            var path = Path.Combine(documentsPath, sqliteFilename);

            // This is where we copy in the prepopulated database
            Console.WriteLine(path);
            if (!File.Exists(path))
            {
                var s = Forms.Context.Resources.OpenRawResource(Resource.Raw.TodoSQLite); // RESOURCE NAME ###

                // create a write stream
                FileStream writeStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write);
                // write to the stream
                ReadWriteStream(s, writeStream);
            }

            var plat = new global::SQLite.Net.Platform.XamarinAndroid.SQLitePlatformAndroid();
            var conn = new global::SQLite.Net.SQLiteConnection(plat, path);

            // Return the database connection
            return(conn);
            //return null;
        }
Example #2
0
        public global::SQLite.Net.SQLiteConnection GetConnection()
        {
            var sqliteFilename = "M2ESQLite.db3";
            string documentsPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
                // Documents folder
            var path = Path.Combine(documentsPath, sqliteFilename);

            // This is where we copy in the prepopulated database
            Console.WriteLine(path);
            if (!File.Exists(path))
            {
                var s = Forms.Context.Resources.OpenRawResource(Resource.Raw.TodoSQLite); // RESOURCE NAME ###

                // create a write stream
                FileStream writeStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write);
                // write to the stream
                ReadWriteStream(s, writeStream);
            }

            var plat = new global::SQLite.Net.Platform.XamarinAndroid.SQLitePlatformAndroid();
            var conn = new global::SQLite.Net.SQLiteConnection(plat, path);

            // Return the database connection 
            return conn;
            //return null;
        }
Example #3
0
		public global::SQLite.Net.SQLiteConnection GetConnection ()
		{
			var sqliteFilename = "TodoSQLite.db3";
			string documentsPath = Environment.GetFolderPath (Environment.SpecialFolder.Personal); // Documents folder
			string libraryPath = Path.Combine (documentsPath, "..", "Library"); // Library folder
			var path = Path.Combine(libraryPath, sqliteFilename);

			// This is where we copy in the prepopulated database
			Console.WriteLine (path);
			if (!File.Exists (path)) {
				File.Copy (sqliteFilename, path);
			}

			var plat = new global::SQLite.Net.Platform.XamarinIOS.SQLitePlatformIOS();
			var conn = new global::SQLite.Net.SQLiteConnection(plat, path);

			// Return the database connection 
			return conn;
		}
Example #4
0
        public global::SQLite.Net.SQLiteConnection GetConnection()
        {
            var    sqliteFilename = "TodoSQLite.db3";
            string documentsPath  = Environment.GetFolderPath(Environment.SpecialFolder.Personal); // Documents folder
            string libraryPath    = Path.Combine(documentsPath, "..", "Library");                  // Library folder
            var    path           = Path.Combine(libraryPath, sqliteFilename);

            // This is where we copy in the prepopulated database
            Console.WriteLine(path);
            if (!File.Exists(path))
            {
                File.Copy(sqliteFilename, path);
            }

            var plat = new global::SQLite.Net.Platform.XamarinIOS.SQLitePlatformIOS();
            var conn = new global::SQLite.Net.SQLiteConnection(plat, path);

            // Return the database connection
            return(conn);
        }