Closed vbudilov closed 8 months ago
Just to confirm, this is happening only on Android. Here's my main.android.kt file:
import android.annotation.SuppressLint
import android.content.Context
import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.LocalContext
@SuppressLint("StaticFieldLeak")
var context: Context? = null
@Composable
fun MainView() {
context = LocalContext.current
App()
}
actual fun pathTo(id: String): String = "${context?.filesDir?.path}/$id.json"
context?.filesDir?.path
gives you the absolute path - and I think you need the relative one. You should be able to do
actual fun pathTo(id: String): String = "${context.filesDir}/$id.json"
Also, don't keep a static reference to context 😅
Thanks for this awesome library!
I've set it up as per your instructions but when I go to use it I'm getting the following exceptions (essentially it can't create the directory or it can't store the file due to a read-only FS. Did I miss a permission request or something?
How I initialized it
private val store: KStore<JWTTokens> = storeOf(filePath = "tmp/jwt.session")
with 'tmp'
without the 'tmp' prefix
java.io.FileNotFoundException: jwt.session: open failed: EROFS (Read-only file system)