https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
g

Guilherme Germano Silva

03/02/2024, 3:50 PM
Hello guys, it's my first time doing apps for IOS and I facing one difficulty. On my amp project I want to verify if my database exists, because if not I ll create with some default data but on IOS change the database location every time and my check not working, someone can help me please? This is my code
Copy code
actual class DriverFactory {
       actual fun createDriver(): SqlDriver {
        val paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, true)
        val documentsDirectory = paths[0] as String
        val databasePath = "$documentsDirectory/Automorama2Database.db"

        val exist = NSFileManager.defaultManager.fileExistsAtPath(databasePath)

               println(databasePath)
               println("$exist")
               val nativeSqliteDriver =
                       NativeSqliteDriver(Automorama2Database.Schema, "Automorama2Database.db")
               if (!exist) {
                       createCombustiveis(nativeSqliteDriver)
               }
               return nativeSqliteDriver
       }
}
``````