Flutter Hive - how to locate box files

1,834

Solution 1

Solved this by selecting a Project SDK from File > Project Structure

I then had to make sure I was using an Android Virtual Device with a system image that did not support Google Play store (Pixel 2XL with Android 8 I think, just picked anything without Play).

There is an issue where if you're using an AVD with Google Play loaded you won't be able to access the default folder where Hive puts your .hive files

Your Hive files by default, at least on Android with Flutter, seem to go into this path - /data/user/0/yourapplicationv1.yourapplicationv1/app_flutter

Hopefully this helps anyone experiencing the same issue

Solution 2

In the case of iOS, you can check it by following the steps below.

  1. First, check the identifier of the simulator you are using in the application you are developing, which can be found in xcode under Window → Devices and Simulators. The identifier is usually formatted something like B8D6964E-01BD-4D90-96CA-746F87AF3F48.

 2. run $ cd ~/Library/Developer/CoreSimulator

 3. run $ cd YOUR-SIMULATOR-IDENTIFIER

 4. run $ find . -name "*.hive" -ls

This will probably find the .hive file. However, in order to see the contents of this file, you will need to install Hadoop and Hive.

I haven't tried it because it seems a bit time-consuming, but I'll post a link that might be useful.

how-to-install-hive-on-mac-with-homebrew

Share:
1,834
mav91
Author by

mav91

Newbie coder looking to master programming so I can make software whenever I'm irritated with a current solution. Currently working through Learn Ruby The Hard Way.

Updated on November 23, 2022

Comments

  • mav91
    mav91 over 1 year

    This may be obvious, but can someone please tell me how I can locate my Hive Box file after initialising Hive in a Flutter application, using Android Studio?

    I have followed the documentation here - https://docs.hivedb.dev/#/README - and my basic implementation works o.k, but I cannot find where the Box file, or any Hive files for that matter, are stored.

    I want to be able to locate where my Box (database) is within my Project in Android Studio, so that I can see the contents of the database and confirm it exists in the right place

    This is my code where I'm initialising Hive and opening a box

    void main() async {
      // Initialise Hive
      await Hive.initFlutter('hiveusersfolder');
      runApp(MyApp());
      var box = await Hive.openBox('hiveusersfolder');
      box.put('name', 'MyName');
      print('Name: ${box.get('MyName')}');
    }
    

    The above code is present in my main.dart file

    I am using Android Studio on Ubuntu.

    *Edit update

    I have located the supposed path of where the Box is stored, but when using Android Studio Navigate > Search Everywhere - there is nothing found within this folder/path. After initialising my database and adding a user to the box, I should be able to see a box file and view the users like with any other kind of db no?

    This is the path /data/user/0/myappv1.myappv1/app_flutter

    I tried Invalidate Cache + Restart, but still nothing

    If the problem is with Android Studio search, how can I access the above path on Ubuntu file explorer? Or using the command line?

  • Gem
    Gem over 2 years
    Once you find the .hive file, how did you open it ? any software/tool which we can use?