public static void Startup() { SQLiteConnection connection = null; string dbLocation = "expensesDB.db3"; #if XAMARIN_ANDROID var library = Environment.GetFolderPath(Environment.SpecialFolder.Personal); dbLocation = Path.Combine(library, dbLocation); var platform = new SQLitePlatformAndroid(); connection = new SQLiteConnection(platform, dbLocation); #elif XAMARIN_IOS var docsPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal); var libraryPath = Path.Combine(docsPath, "../Library/"); dbLocation = Path.Combine(libraryPath, dbLocation); var platform = new SQLitePlatformIOS(); connection = new SQLiteConnection(platform, dbLocation); #elif WINDOWS_PHONE var platform = new SQLitePlatformWP8(); connection = new SQLiteConnection(platform, dbLocation); #endif ServiceContainer.Register <IExpenseService>(() => new ExpenseService(connection)); ServiceContainer.Register <IMessageDialog>(() => new MessageDialog()); ServiceContainer.Register <ExpensesViewModel>(); ServiceContainer.Register <ExpenseViewModel>(); }
public SQLiteConnection GetConnection() { const string sqliteFilename = "TodoSQLite.db3"; //データベース名 var path = Path.Combine(ApplicationData.Current.LocalFolder.Path, sqliteFilename); //DBファイルのパス var plat = new SQLitePlatformWP8(); var conn = new SQLiteConnection(plat, path); return(conn); }