I am using few json files and i want them to be loaded into hive.
Do you have any tool to migrate data from json to hive?
You have multiple options: If you just want to store json data, you can use box.put('someKey', yourJson) where yourJson is of type Map<String, dynamic>.
You can also use box.putAll(yourJson). This will store each key-value pair as one entry in Hive.
The third option is to map the json to objects (there are good tools for example json_serializable) and then store the objects in Hive.
Thanks.
I am not able to find the hive boxes.
May i know where is it stored by default?
final appDocumentDir = await path_provider.getApplicationDocumentsDirectory(); Hive.init(appDocumentDir.path + 'hive');
I searched the app with .hive extension and found nothing
They are stored in the directory you specify when calling Hive.init() in your case appDocumentDir.path + 'hive'
But I think your code will fail because you missed a path seperator: appDocumentDir.path + '/hive' should work.
appDocumentDir.path + '/hive'
Changed the code as you mentioned. But i am still not able to find the directory and hive boxes.
Oh you are using Hive on Desktop? I don't think the path_provider package works on Desktop.
You can just use Directory.current.path.
Yes it is desktop. Using Hive with Flutter
Hive.init(Directory.current.path + '/hive');
runApp(MyApp());
E/flutter (11105): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: FileSystemException: Creation failed, path = '//hive' (OS Error: Read-only file system, errno = 30)
Actually i have a data folder in my app and with few json files.
I read about hive and decided to convert my code for hive.
Hive looks easier and i can replace the "shared_preferences" to hive.
Can you please share some coding?
How do i start the app with some pre-filled hive boxes?
You just need to give Hive a valid path where you have write permission. It seems like the provided path is not valid on your machine.
@maheshkumar2150 how do u solve it? Same here!
@maheshkumar2150 how do u solve it? Same here!
Do you see the same error or are you also trying to load json data?
@maheshkumar2150 how do u solve it? Same here!
Do you see the same error or are you also trying to load json data?
Same error, solved using getApplicationDocumentsDirectory()
@maheshkumar2150 how do u solve it? Same here!
Do you see the same error or are you also trying to load json data?
Same error, solved using
getApplicationDocumentsDirectory()
In which location .hive file created?
I am using different nosql (Sembast) package on my project.
But i am thinking to use hive in few other projects because of its simplicity.
@maheshkumar2150
In which location .hive file created?
In the directory you provide when you call Hive.init()
Can I export hive box to a JSON file?
Can I export hive box to a JSON file?
Of course you can