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.
Related
What am I trying to achieve: Based on some filters by the app user, I want to return a list with text and images.
How am I doing it: I have created a table in Parse and have added a column with object type as 'file'. I have put all the jpg/gif images into that column. (double-click, browse, select image from local computer).
The trouble I am having is, the list takes considerable time (~7 seconds) before it is displayed on my android app.
Is there a better way of handling image data within Parse or should I store images somewhere else (like Amazon S3)?
I am using standard queries for Parse in order to get data, nevertheless, am also checking if there is any code latency. Wanted to confirm if I am correctly handling the image data for back-end or not.
Is there a better way of handling image data within Parse or should I
store images somewhere else (like Amazon S3)?
If your images is not too much or you are using for example(five image) its better to save the into the Assets or Drawable Folder for loading.
and if i correctly knows about this problem, you need to use ProgressBar and one image, before loading the Images in Internet.
Caching images and displaying
Hope this helps.
I am using Parse to store images too, but it's not slow as you said. Since Parse is part of Facebook, I think their infrastructure is the same. There are possible issues:
Internet connection: Slow or on 3G?
Images: files are big?
Let me know which case you are in.
If you just display thumbnail images, I suggest you to process it before saving to Parse by writing Cloud function as describe on their blog. The you just need to use generated thumbnails on your listview/gridview
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.
I want to use a large set of images in my application, that are used in a gallery view. However using the res folder seems not possible with larger set off images. What is the best way for including the images into my apk?
You can save the images in a database and add your database to the apk (a way to do so described here. You would read images from the database using Cursor.getBlob
Storing all the images in the res folder will be quite a hefty job so what I recommend is that you save all the images on a web server. And then retrieve the required images from their respective URL's. The following link has a full tutorial on retrieving images from a particular URL.
How to download and save an image in Android
Hope it helps.
I am making a game in which I want user to give some featured items at run time from server. Currently I am saving images as Blob in sqlite db and that is really putting bad impact in overall performance.
If I write images on SD card then there are following possible two scenarios.
1) All mobiles do not have SD card
2) Any one can see/reuse/delete images
I don't want these things to happen. Is there any way that I can save images in drawable folder where no one except me can see images?
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.