/// <summary> /// Constructs a new SQLiteConnection and opens a SQLite database specified by databasePath. /// </summary> /// <param name="databasePath"> /// Specifies the path to the database file. /// </param> /// <param name="storeDateTimeAsTicks"> /// Specifies whether to store DateTime properties as ticks (true) or strings (false). You /// absolutely do want to store them as Ticks in all new projects. The default of false is /// only here for backwards compatibility. There is a *significant* speed advantage, with no /// down sides, when setting storeDateTimeAsTicks = true. /// </param> public SQLiteConnection(string databasePath, SQLiteOpenFlags openFlags, bool storeDateTimeAsTicks = false) { if (string.IsNullOrEmpty(databasePath)) { throw new ArgumentException("Must be specified", "databasePath"); } DatabasePath = databasePath; SQLite3.SetDirectory(/*temp directory type*/ 2, Windows.Storage.ApplicationData.Current.TemporaryFolder.Path); Sqlite3DatabaseHandle handle; // open using the byte[] // in the case where the path may include Unicode // force open to using UTF-8 using sqlite3_open_v2 var databasePathAsBytes = GetNullTerminatedUtf8(DatabasePath); var r = SQLite3.Open(databasePathAsBytes, out handle, (int)openFlags, IntPtr.Zero); Handle = handle; if (r != SQLite3.Result.OK) { throw SQLiteException.New(r, String.Format("Could not open database file: {0} ({1})", DatabasePath, r)); } _open = true; StoreDateTimeAsTicks = storeDateTimeAsTicks; BusyTimeout = TimeSpan.FromSeconds(0.1); }