Пример #1
0
		public static GeofenceDatabase From (Context ctx)
		{
			var db = ctx.OpenOrCreateDatabase ("occurences.db", Android.Content.FileCreationMode.WorldReadable, null);
			var path = db.Path;
			db.Close ();
			return new GeofenceDatabase (path);
		}
Пример #2
0
 public static void CopyDatabase(Context context, string dbName)
 {
     using (Stream istream = context.Assets.Open(dbName))
     {
         using (SQLiteDatabase db = context.OpenOrCreateDatabase(dbName, FileCreationMode.Private, null))
         {
         }
         using (Stream ostream = new FileStream(context.GetDatabasePath(dbName).AbsolutePath, FileMode.Open))
         {
             byte[] buffer = new byte[1024];
             int length = 0;
             while ((length = istream.Read(buffer, 0, buffer.Length)) > 0)
             {
                 ostream.Write(buffer, 0, length);
             }
         }
     }
 }