Example #1
0
        public void CopyDatabase(string path)
        {
            string   prefix = "";
            DateTime time   = DateTime.Now;

            prefix += $"_{time.Year}_{time.Month}_{time.Day}_{time.TimeOfDay.Hours}_{time.TimeOfDay.Minutes}_{time.TimeOfDay.Seconds}";
            Java.IO.File dsFile = new Java.IO.File(path, DatabaseName + prefix + ".sqlite");
            Java.IO.File dbFile = new Java.IO.File(this.ReadableDatabase.Path.Substring(0, this.ReadableDatabase.Path.Length - DatabaseName.Length - 1), DatabaseName);

            FileChannel inChannel  = new FileInputStream(dbFile).Channel;
            FileChannel outChannel = new FileOutputStream(dsFile).Channel;

            try
            {
                inChannel?.TransferTo(0, inChannel.Size(), outChannel);
            }
            finally
            {
                inChannel?.Close();
                outChannel?.Close();
            }
        }