I follow this Instruction and it works.
Problem:
Every time I exit my application I need to capture again another image but the image that was been capture is save in the android gallery
Question:
How can I save the image in database so when I open my application the image will be their.
Unlike some comments suggest, image format doesn't matter. You can either save it as BLOB (byte[]) or text (converting it to Base64).
Anyway it's not a good idea to store images in a DB, prefer a file, as argued over here.
i will advice you get the path at which the image is located at in the android device and load up on your application start. the case of saving it in a database is not cool. that is like consuming the user's memory space on the database side and also the device storage which is not cool.
Related
This question already has answers here:
What is the best way to store the image in the memory of app?
(4 answers)
Closed 6 years ago.
I'd like to be able to programmatically work with Images, ImageViews, Drawables, and SQLite blobs (byte arrays). I inevitably want to be able to have a program that lets me acquire images from the Gallery app or something similar (ie camera), and then place them in a gallery construct within my app and work with them from there. Storing them in SQLite database's as needed.
I haven't come across anything that works. Much of it is deprecated. I have a simple project that is working with text in a SQLite database, and am now trying images.
If you can show or send me someplace that shows how to work with these constructs that would be great. Though to be more specific for this thread I'll state a few things I'd like to do:
Converting Drawables to ImageViews and converting Drawables to SQLite blobs.
Acquiring images from outside the program and placing them in the Drawables section.
Best constructs for working with images.
Thanks,
convert a image to byte[] and easy to store SQlite db
Don't store images in SQLite, instead of saving images save their path into SQLite, and later you can load image from their path.
and if you are loading images from web then you can use Universal Image Loader. It will display and store images in device memory and you can load images offline anytime with same url.
Instead of saving image as blob, save the image url. Or save it in external file in sd card or phone memory.
To save it in a link,
When the user selects an image from gallery. Call the upload image function ( it can be a BoundService ). You can find it by googling it.
When the upload image is successfull, ull get the image url in Json.
Just save that image link in your sqlite database.
Hope it helps.
I want to make image backup through my Application what is the best way for storing large amount of data . I tried to save image in sqlite database it worked fine for small amount of data in case of large amount it shows MemoryOutOfBoundExceptions after increasing the Heep size(android:largeHeap="true").
please help me guys .
If you want to save only image or any file try to save only path of that file in database.After that you can get file path by normal SQL query and access file from file path.
Instead of Storing Large data in Application you have to store it DataBase so it will speed up your Application and you have no Exception produce like OutOfMemoryException in your Application.
You don't store images in databases, that makes the database huge and slows it down. Store the images to disk and store the path to the file in the database. This will make the database a lot lighter and faster.
If you're developing for Android, i'd also recommend using something like Picasso, Fresco or Glide to display your images too. They cache the image and use memory efficiently when doing operations like scaling images.
What is the better approach of hiding selected images from the gallery from my application.
Changing the extension of the image with some extension
Problem with appraoch 1: Using file explorer we can view the images
Encryption of images
Storing the images in our local database and deleting the image from the location
Please can any one suggest the best appraoch
1. Chnaging Extention: This is not a good way to do.
2. Encryption of Image: If it is a security reason this is a better ontion but if anyone delete that file then you may face problem.
3. Storing the images in our local database and deleting the image from the location: This is also a good option.
I will suggest you to go with option 3 i.e. Storing the images in our local database and deleting the image from the location.
I need to develop an android app that achieves the following:
Create an activity which takes a picture on a button click.
Once the picture is taken, have two buttons save and compare.
The picture should be saved in a database if save button is clicked.
If compare button is clicked, the picture should be compared with all other pictures in the database.
If the picture matches with the one in the database, the name of the picture stored in the database should be displayed.
I know how to use the Camera API to take a picture. But I don't have an idea of how to save the same picture in a database and compare it with all other pictures in the database.
If my idea is wrong please correct me.
Thanks!
Everything you need is within these tutorials so check this link:
http://thenewboston.org/list.php?cat=6
The logic for comparing the pictures you will have to write yourself though because I can't predict what type of comparison you want. Except that how to connect to db to store data plus getting bitmap from the camera everything is in those tutorials.
Hope this helps!
Don't save the picture in your database. Instead save it on the SDcard/internal storage and save the url in your database. (Simpler approach)
As far as comparing with other pictures, you will need to implement some image recognition/pattern matching algos.
I am writing an app that uses the camera intent to take a picture. I get the uri of the image (which is saved in the gallery) and can display the image in the ImageView. I am trying to figure out the best way to save this uri in the SQLite database in order to retrieve it later and put the image in the ImageView. Do I use a BLOB to store the uri? If so, how would I do this? Or do I convert the uri to a String and store it that way? I've been searching for an answer and I must be using the wrong search words, because I can't find an answer to what should be a simple question.
It would depend on how you want to access it later. For what your're considering there are two options, since the image is already saved on you phone, there is no need to save it twice as a blob. Or if you will move the image on the phone or remove it, having it in a blob would be better.
In reality, you'd be better service saving the image in a directory set aside just for images from your app and then reading all the file names in that directory later for access.