Hey,
Can you please guide me on how can I fetch the existing data of my native(android and iOS) application to the newly built Flutter application?
Note: native app database is encrypted
Thank you in advance
Hey,
Can you please guide me on how can I fetch the existing data of my native(android and iOS) application to the newly built Flutter application?
Note: native app database is encrypted
Thank you in advance
Hi @Prachi_Palkhiwala!
If your app use Atlas cloud and realm with flexible sync it would be easier and you will be able to convert the model classes to dart code and to download the data to a new file dedicated for the Flutter app.
But I suppose you are asking for a local realm file.
It is possible to open an encrypted realm file in flutter if you have the encryptionKey.
First you need to create dart classes that to define the same model as the model in the existing app, for example:
@RealmModel()
class _Car {
@PrimaryKey()
late String make;
}
then run:
dart run realm generate
to generate the RealmObjects classes based on the defined model.
After that you can set the RealmObjects.schema into the list parameter of Configuration.local
, set the encryptedKey and the path to the existing file, as follow:
final encryptedConfig = Configuration.local([Car.schema], encryptionKey: key, path: "absolute path to the realm file");
final realm = Realm(encryptedConfig);
Let me know if you are using flexible sync with the cloud, because you can use the server schema there to convert the model classes to Flutter/Dart and you won’t write them manually.