Last active
October 17, 2023 17:28
-
-
Save igorescodro/160924e045496d8add55e00878232636 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override fun shouldPrepopulateDatabase(databaseName: String): Boolean = | |
!databaseExists(databaseName) | |
private fun databaseExists(databaseName: String): Boolean { | |
val fileManager = NSFileManager.defaultManager | |
val documentDirectory = NSFileManager.defaultManager.URLsForDirectory( | |
NSLibraryDirectory, | |
NSUserDomainMask, | |
).last() as NSURL | |
val file = documentDirectory | |
.URLByAppendingPathComponent("$DATABASE_PATH$databaseName")?.path | |
return fileManager.fileExistsAtPath(file ?: "") | |
} | |
private const val DATABASE_PATH = "Application Support/databases/" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment