Images in sqlite


#1

My application is going rather well but now I need the following.
I want to show images stored in sqlite and also be able to store them there.
I know how to retrieve text but I do not how to handle blobs.

In the app I can use the camera to take pictures and I also like to show pictures in then android gallery viewer. If I use the built-in I need to load the images before and that’s not what I want to do.
I want to be able to show images on the cell phone and then select the I need to store in the database and to show on the screen.

Ok, I found how to start the gallery app (see attachment) but how to return a picture from it and how to catch in activitystarter.afteractivity?


#2

You’ll need to store the image path, not the actual image


#3

You could also do a base64 conversion of the image so you can store it as a string.

Cloudinary and Firebase Storage are options to store your media assets, for you as well.


#4

Ok that is a possible solution.
But I want to export may database and work with on the pc through ODBC.
WIth this solution I will not store my image as blob and I will have problems accessing it from somewhere else.

The image picker


With these blocks I can open the galleryviewer to pick an image but the activitystarter.afterpick gets an empty result.
How to resolve this?

When using the camera I can get the picture taken but it is always rotated 90° to the left, any way around this?


#5

There is a builtin component. Is there a reason you are not using it?

image


#6

The galleryviewer shows the images given to it in its picturelist.
It does not show all pictures on the phone, so no I cannot use it.


#7

Have a look at the blocks here. They use a PICK option. Does this help?

https://puravidaapps.com/snippets.php#2imagepicker


#8

Well on the page they say it has problems with Android Pie and I am running Pie.
The first time I use this I get the error 601 no corresponding activity was found.

If I use


And look after the pick to ActivityStarter.ResultURI I get the path to the image.

If I than use the first method it does work.
Anyway I now have a way to select them without copying.


#9

I’m trying now with a base64 string.
I can store the data but how to retrieve it.
When I do a select I get a list back surrounded by [()].
I can do a replacetext to remove [, ], ( and ) but I’m not sure if other occurrences af these characters are in the base64 string.
Anyway when I strip them the image is showing nothing.
Can anybody help ?


#10

No the base64 will NOT have any special characters. Once you get the string you need to decode it. That will then convert it to an image.


#11

Ok, I’ll try again.
But what about saving an image as an image and not as text?
Storing the image as text doubles the size.
If I have to stick to base64 encoding is there a decoder to use under windows?
I want to export/import the database and use it in Access through and ODBC link


#12

I’m using activitystarter for calling the galleryviewer to get content.
I’m using the resulturi to give to the image picture path.
The image shows ok but when I try to use base64 encoding this fails complaining about a null object.
If I inspect the picture path I get
content://media/external/images/media/
this is a non-existing path but the image shows ok.

How to get the correct path from galleryviewer GET_CONTENT?


#13

you might want to use the GetFilename method from the file extension https://puravidaapps.com/file.php

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.