Hi ,can somebody share an example okio used in kmm...
# multiplatform
r
Hi ,can somebody share an example okio used in kmm project or a sample project ,the GitHub sample and docs not that comprehensive
j
What specifically are you wanting to do?
r
i have some html files in common main , now i want write common code to copy that file into device storage if its possible ,
both android and ios
j
Are these html files in code or resources?
r
In common resources Mr folder I have used moko as well
j
I describe how I'm doing this here for Android, iOS, JVM, Linux, and Windows. Besides using Okio or another API to get the resources from the respective target's resources or file system, you also need to ensure the resources are actually copied to the bundle, framework, or runtime path, which I also describe in that thread. What platforms are you targeting?
r
only android and ios
i went through the thread you provided, in my case i just wan to copy it to device storage my files are in common main resources folder, do you have any sample project for this i really trying hard to get this done thanks
j
My examples in the thread are how to ensure the files from common main resources are in the app bundle or framework for the app to access. Copying them from there to another location on the file system varies depending on the platform. So there's not really a common way to do this with only Okio or any other library I'm aware of. You need a
Context
reference on Android in order to interact with the bundle resources or application sandbox file system. On iOS, you need
NSBundle
to access the resources from the framework and
NSFileSytem
to write to the app's documents directory. I'd recommend implementing this in platform specific code, androidMain and iosMain. You'll need to pass a reference to the
Context
on Android, so the API doesn't align with an expect/actual.
381 Views