I’m writing an application that will ship in two versions: Android and PC version.
Is there a simple way to access files from the shared code?
Using java.io is simple, but I don’t know how to access android resources or assets using it. And I can’t write methods that operate on FileInputStreams instead, because some files contain references to another ones, so I need a way to access them from the method code.
Any suggestions?
PCs do not have “resources or assets”. By virtue of wanting to use “android resources or assets”, you are already committed to not treating Android and the PC the same way.
So, write yourself a Java interface that gives the rest of your code access to whatever data you want. Write two implementations of that interface, one that uses
java.iofor files on the PC, one that usesResourcesfor Android.