Closed raghavtilak closed 2 years ago
Hi @raghavtilak, you need to init the RoomBackup before calling the onClickListener. See Documentation and Sample.
Hii @rafi0101 Please see my current code, I have instantiated the roombackup outside the listener, but am still getting the same error.
RoomBackup roomBackup = new RoomBackup(requireActivity());
roomBackup.database(AppDatabase.getInstance(requireActivity()));
binding.backupLocally.setOnClickListener(view -> {
roomBackup.backupLocation(RoomBackup.BACKUP_FILE_LOCATION_CUSTOM_DIALOG);
roomBackup.maxFileCount(5);
roomBackup.onCompleteListener((success, message, exitCode) -> {
});
roomBackup.backup();
});
Oh I see you are using this within a fragment. I haven't tested this yet.
Have you tried initiating it yet like in the Java example line 207 and 212? Otherwise, I would take a look at it in the next few days.
Oh I see you are using this within a fragment. I haven't tested this yet.
Have you tried initiating it yet like in the Java example line 207 and 212?Otherwise, I would take a look at it in the next few days.
Yes I have tried it initialising like this, but still the same error. Ohk! Please have a look.Thanks
I tested it with fragments, and found a way to fix your problem.
You need to initialize RoomBackup in the parent Activity from your Fragment. For further information see the updated doculmentation.
Please tell me if this works for you
Yeah this works!! 😄 Thanks 👍🏻
Describe the bug I just added the java code snippet for backup, but the app crashed with the following error, on googling a bit found that this must be because of performing the registerForActivityResult on the activity. LOGS-
Expected behavior Should have shown the dialog for file location,and have backed up the db.
Screenshots
Smartphone (please complete the following information):