https://kotlinlang.org logo
Title
l

Lucas

05/10/2023, 7:36 PM
Is it possible to use exposed in android? I have found some mixed results
I'm going to try it now, just asking in advance in case i fail
I was able to do it by using xerial
a

Andrew O'Hara

05/11/2023, 2:59 PM
You mean the xerial jdbc adapter for sqlite? Good to know you had no issues. I couldn't think of any reason it wouldn't work, but I had no experience to back it up.
l

Lucas

05/11/2023, 6:42 PM
Yes I found a lot of mixed results in the github issues, some suggesting it was not possible to use xerial, others simply saying that they were using exposed on android but with no further explanation (most are just very old/outdated) Xerial was pretty easy to configure, just add the gradle dependency and copy the .so files to the jniLibs in android (and rename the folders) Other important setting was the database path which has to be under
"/data/data/$packageName"
Since i'm reusing the same tables for my backend and android database, i also have to use the SQLite "ATTACH DATABASE" for handling schemas, which seems to be working so far
Database.connect("jdbc:sqlite:/data/data/$packageName/files/SCHEMA1.db",setupConnection = {
    it.run {
        createStatement().execute("ATTACH DATABASE '/data/data/$packageName/files/SCHEMA2.db' AS SCHEMA2;")
    }
})