Search Unity

Question SQLite database not working on Hololens 2, although build and debugging are without error

Discussion in 'AR' started by Dia-su, May 26, 2023.

  1. Dia-su

    Dia-su

    Joined:
    Sep 2, 2021
    Posts:
    3
    First, I consider myself a beginner with Unity, SQLite and Hololens. So I very much appreciate it if any answers or help you can give are explained as simply as possible. Thanks in advance!

    I followed a Microsoft tutorial (https://learn.microsoft.com/en-us/training/modules/learn-mrtk-tutorials/) and made a simple (test) app for Hololens 2. Everything is working as it should on the Hololens 2 with the exemption of a database.

    I have a TMP game object that should get its text from a database. The TMP game object has some default text that is first deleted and should then be replaced with text from the database with the help of a script. I use SQLite (I used several tutorials, such as
    ). It works perfectly in the unity editor, but not on the Hololens 2 itself. I have zero errors for the build and zero errors while debugging.

    I used the 2021.3.14f unity editor and have Visual Studio 2019 (there are problems with the newest VS and Hololens 2, so I kept the 2019 version). I follow the above mentioned Microsoft tutorial and use Visual Studio for debugging. The database is a .db file and is saved in the project folder (i.e. outside the assets folder).

    I do not know what happens because - as mentioned - no errors are given. The TMP game object is simply empty. This at least tells me that the script is found/working.

    There are some threads here and on other websites on problems with SQLite and Hololens 2. But all of them mention either errors on build or SQLite is not working at all or the questions are too old (and their solutions do not work any longer). Again, I have zero errors and SQLite is at least working in the editor.

    While searching for a solution I came across several possible reasons for my problem:
    a) I have the wrong dll for SQLite? Some website mention a dll for the UWP, but I have not found out where to get such a dll or how to generate one. I also do not know if I really need such a dll....
    b) The database is not found in the build? I did not find the db file as part of the build folder, but maybe its named differently in the build? I have not found an answer to that question and quite frankly, do not know enough about the build process to check that possible reason.
    c) The database is not part of the build and because of that not found? Maybe because the database is not part of the asset folder, the database is not part of the build. Again, I lack knowledge on the build process to follow that possible problem direction.
    d) The database is empty in the build? One website mentioned that Unity deletes database in build. I have not found an explanation for this supposed behaviour and no solution.
    e) Something is missing on the Hololens to execute the script correctly?

    Instead of using an existing database, I also tried to create a database during runtime. This works again in the editor, but not on the Hololens. Not sure if that information helps.

    I am thankful for any kind of hints or solutions anyone can give me!

    (I did not include scripts in this thread, as I do not think any of my scripts are the problems because everything works in the editor. But of course I can supply the scripts if needed.)
     
  2. Dia-su

    Dia-su

    Joined:
    Sep 2, 2021
    Posts:
    3
    Update: With
    Code (CSharp):
    1. StorageFolder sessionParentFolder = await KnownFolders.PicturesLibrary
    from https://gist.github.com/julenka/20ece5141e821cb6d0a9cb530d3dc96d I was able to test, that the Hololens finds its picture folder and can create a folder there, but still cannot use a db file at the same location.
    Additionally, I tested another type of file (csv file) in the Resource folder in Assets and the Hololens can open this csv file. So b), c) and d) seem to not be the issue.
     
    Last edited: May 29, 2023
  3. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,980
    Are you using IL2CPP? if not, you must use IL2CPP
     
  4. andyb-unity

    andyb-unity

    Unity Technologies

    Joined:
    Feb 10, 2022
    Posts:
    1,062
    makaka-org likes this.