Example #1
0
        private void CopyDatabaseFile(string dbPath)
        {
            var destPath = System.IO.Path.Combine(Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryDocuments).AbsolutePath, "database.db");

            // Destination
            var destFile = new Java.IO.File(destPath);
            var canWrite = Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryDocuments).CreateNewFile();
            var canRead  = Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryDocuments).CanRead();

            if (!destFile.Exists())
            {
                try
                {
                    var result = destFile.CanWrite();
                    destFile.CreateNewFile();
                }
                catch (Java.IO.IOException ex)
                {
                    System.Diagnostics.Debug.WriteLine($"Error Message: {ex.Message}");
                    System.Diagnostics.Debug.WriteLine($"Error Source: {ex.Source}");
                }
            }
        }