Can I use blob data with Bundle on Android?

1

I have to upload images to a database (with blob ), but it receives the data from Bundle , I have tried several things and I get an error due to the type of file I try to upload and I would like to know if you can use Bundle in this way.

The code used by Bundle is this (the code is not mine, I do not know how it works):

Bundle datos = new Bundle();
datos.putString("NombreCampo", CampoBD);
datos.putString("NombreCampo", CampoBD);
...

I would like to know if in that datos.putString() I can put a blob

    
asked by OniNeit 27.07.2017 в 13:48
source

2 answers

3

You can do it the way you indicate, but preferably you should encode to base 64 :

String imagenCodificada = Base64.encodeToString(byteArrayImage, Base64.DEFAULT);

Personally to avoid memory problems or corrupted data, I prefer to send in the Intent the url of the image, or even save in the database the url.

    
answered by 27.07.2017 / 16:09
source
1

With putString you can put a String.

If you have binary data, you can code it as base64 to have a representation as string at the cost of increasing the number of bytes.

If you save it in the database in this way it will not be a blob but a very long string.

You can also decode base64 to binary before doing the insert in the database, in that case the data is saved as blob and the increase in size would be only to be able to send it from one Fragment to another in the Bundle ( If that is what this Bundle is used for in particular).

    
answered by 27.07.2017 в 15:45