Android Question Use ExternalStorage to output Bitmap

Wosl

Member
Dear All,

Sometimes a mental block hinders us to see the obvious solution. Here is one case:

I try to output an internal generated bitmap to an external file via the ExternalStorage logic. This code snippet shows how I realized an export of a string (build with stringbuilder):
B4X:
        '  Copy a string to inputstream
        inputstream = StringToInputStream (cCSV)

        '  Allocate a new file on external device
        DestinationFile = Storage.CreateNewFile(extFile,cFileCSV)
        outputstream    = Storage.OpenOutputStream(DestinationFile)

        '  Copy string to external device
        File.Copy2(inputstream,outputstream)

        '  Close streams
        outputstream.Close
        inputstream.Close

Now I try to export instead a string variable (here: cCSV as String) a bitmap (like bmp as Bitmap) but I could not find out how to copy the byte stream of a bitmap to an inputstream. Generally spoken, how to use any byte stream (like a bitmap) together with ExternalStorage.

This questions seems to be quit simple but I can't figure out how to do it.

Any help is appreciated.

Wosl

This question seems to be simple
 

Wosl

Member
Erel, Thank you very much. As I said it's easier as expected ... no need to convert first to a byte stream and secondly copy it to InputStream.

I'll put this snippet in my code and test it.

Wosl
 
Upvote 0
Top