I've not worked with files much in B4A and I'm assuming that the answer I'm looking for will require some sort of InputStream / OutputStream work.
I'm adding to the Wearable DataLayer lib the methods to extract a bitmap or file held within an asset.
For Bitmap I think I have it covered by following Googles docs. This the code for that
public Bitmap GetBitmapFromAsset(Asset asset) {
if (asset == null) {
throw new IllegalArgumentException("Asset cannot be null");
}
InputStream assetInputStream = Wearable.DataApi.getFdForAsset(mGoogleApiClient, asset).await().getInputStream();
if (assetInputStream == null) {
return null;
}
return BitmapFactory.decodeStream(assetInputStream);
}
but I' a little stumped for how to go about it for files. Do I just return the InputStream? Or do I get the user to pass a TargetDir and TargetFilename and save the file to the filesystem. If the latter, how on earth do I go about that? I was hoping there was something similar to the Bitmap solution like new FileFromStream but I cannot find such thing.
Cheers