Reputation: 4050
I'm confused about what low level operations are happening when I get an InputStream to an android resource (or asset). Is the input stream pointing to an actual file on disk that I could potentially access via UNIX-style read() and write() via JNI. Or is the InputStream some sort of special wrapper that points into the APK ZIP file, in which case ugly decompression operations would be going on each and every single time you do a read() call.
If the case is the latter, then how the heck do you get good IO performance on something like a video resource on Android? What if you want to write a video player that can seek back and forth through a video file, and just generally have good IO performance?
Must I really initially store the video file as an asset, and then do a silly manual copy of it to disk via openFileOutput() the first time my app runs?
Upvotes: 3
Views: 229
Reputation: 15108
Video files are usually not compressed as i mentioned here: If I don't compress a plain text file in Android, will it be compressed in the APK anyway?
Furthermore since uncompressed files in the apk are aligned using zipalign they can be accessed using mmap().
In case you want to investigate how access to those files is implemented AssetManager and AssetFileDescriptor might be a good place to start.
Upvotes: 1