where is stored the .db file of Room in Compose De...
# multiplatform
p
where is stored the .db file of Room in Compose Desktop from Kotlin Multiplatform?
h
where you specify the path lol
p
well, it's from the tutorial I think: val dbFile = File(System.getProperty("java.io.tmpdir"), "my_room.db")
how can I do that the file is stored on the program folder?
h
welp you can print the
dbFile.path
and find out?
p
C:\Users\user\AppData\Local\Temp
do you know how can I change that folder to application folder?
well, achieved it using
val dbFile = File("output/db.db")
b
just a heads up, I've been doing a desktop app and only recently built the executables. The location it generally gets saved unless you specify where, won't be allowed when you make them, and it'll be read only. For example in windows it needs to get saved in the appdata dir, and on mac in 'library/application support'. There might be other options as well, but the default option won't be right.
p
what do you mean? you mean that val dbFile = File("output/db.db") will not work in some circunstances? I mean, if the user of the executable puts the file in a folder, or in desktop, it should work, as the user has permissions on folders created by the user or in his desktop
b
I was using sqldelight, but the default folders that worked on android/ios didn't work on mac or windows and I assume linux, and it was only after creating the executables that i encountered the problem. Running it with Android Studio while developing didn't cause any issues.
p
what is the default folder for you?
my line will store the db on the same folder the executable is located I think, but I still didn't check it
b
I had done this originally
Copy code
JdbcSqliteDriver("jdbc:sqlite:LiveDatabase.db")
And this was saving it in the root folder of the android studio project. Now its
Copy code
JdbcSqliteDriver("jdbc:sqlite:${getWorkingDir()}/LiveDatabase.db")
which points to the data folders for mac/windows (still haven't set it up for linux). I'm still looking for a better way to generate the working directories though, i'm not happy with what I have, and a library I tried caused crashes.
Also you're using room so maybe it'll be different in how it saves them... but as a heads up if your database is read only when you compile the executables, that might be why
p
ok thank you I'll remember this