private void CreateDatabase(bool makeCurrent) { var keyfileCheckbox = FindViewById <CheckBox>(Resource.Id.use_keyfile); string password; if (!TryGetPassword(out password)) { return; } // Verify that a password or keyfile is set if (password.Length == 0 && !keyfileCheckbox.Checked) { Toast.MakeText(this, Resource.String.error_nopass, ToastLength.Long).Show(); return; } //create the key CompositeKey newKey = new CompositeKey(); if (String.IsNullOrEmpty(password) == false) { newKey.AddUserKey(new KcpPassword(password)); } if (String.IsNullOrEmpty(_keyfileFilename) == false) { try { var ioc = IOConnectionInfo.FromPath(_keyfileFilename); using (var stream = App.Kp2a.GetFileStorage(ioc).OpenFileForRead(ioc)) { byte[] keyfileData = Util.StreamToMemoryStream(stream).ToArray(); newKey.AddUserKey(new KcpKeyFile(keyfileData, ioc, true)); } } catch (Exception) { Toast.MakeText(this, Resource.String.error_adding_keyfile, ToastLength.Long).Show(); return; } } // Create the new database CreateDb create = new CreateDb(App.Kp2a, this, _ioc, new LaunchGroupActivity(_ioc, this), false, newKey, makeCurrent); ProgressTask createTask = new ProgressTask( App.Kp2a, this, create); createTask.Run(); }