LitBackupService
What is LitBackupService?
LitBackupService is a Flutter package allowing you to create and restore backups using JSON files. This package does implement a very simple persistent (key-value pair) storage on local devices and should only be used as a secondary storage solution (such as for backuping other databases).
It does contain an abstract model class to provide a basic structure how backupable model classes should be defined. The JSON serialization should therefore be performed on each model class individually, as the models varies in structure.
Platform Support
Android |
---|
✔️ |
This package is currently only supported on Android devices.
Screenshots
Example HomeScreen | Example HomeScreen |
---|---|
Required Permissions on Android
In order to read and write outside the app-specific directories, additional
permissions will be required. These must be enabled on the AndroidManifest.xml
of your app located on android/app/src/main
. More recent releases of Android
are managing storage permissions on the file's purpose and therefore have no effect applied.
// Android devices prior to Android 11
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
// Android devices from Android 11
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
In order to access already existing backup files (the currently running app won't be able to access them directly), these permissions must first be granted.
This will be done using the BackupStorage
's requestPermissions()
method,
which uses the permission_handler
package.
Backup location
Backups are stored on the device's Media directories by default. But custom file
paths are supported. The Media directories will include the Documents folder
(default) on /storage/emulated/0/Documents/
or the Download folder on
/storage/emulated/0/Download/
.
We recommend to use the Documents folder as backup location if possible for better security.
But for higher compatibility we recommend to use the Download
folder, due
to it being available on almost all Android devices.
Getting Started
This project is a starting point for a Dart package, a library module containing code that can be shared easily across multiple Flutter or Dart projects.
For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.
Example app
To get a better understanding for implementing the LitBackupService, we recommend
to take a look at the example app provided in the example
folder. Feel free to
experiment with the app.
Dependencies
Leitmotif uses the following Dart dependencies in order to implement certain features and functionality:
- permission_handler - License (Used to request storage access permissions)
Credits
LitBackupService is made possible thanks to the Flutter Project.
License
Everything else in this repository including the source code is distributed under the
BSD 3-Clause license as specified in the LICENSE
file.
Libraries
- controller/backup_storage
- controller/controllers
- A list of controller classes used to achieve certain functionality of this package.
- data/data
- A list of data objects used to store constant data.
- data/file_extensions
- lit_backup_service
- A Flutter package to create and restore backups, whose content is formatted as a JSON files.
- model/backup_model
- model/media_location
- model/models
- A list of model classes used to store and mutate data across this package.