Create image gallery using image paths stored insqlite db - android

I am creating an app which i want to use to report field incidences at work.
Each incident may have one or more photos.
At this stage, i want to store the images locally on sd card and store their paths in the sqlite db.
So far i have figured out the db design and how to capture and save images on sd card and store their paths in the db.
What is challenging me now is how to dispay the images back?
I want a set up that dispalys the incident description and the associated image(s).
I have created xml file with textview to display the incident description and a gallery to dispaly images related to that incident.
My question is how to use image paths to create a gallery...or a better suggestion...
I have written code to retrieve incidences and related images ...
Ronald

Because when every app have some limitation regarding Heap allocation.... when u load images more than allocated heap space it will throw out of memory exception....

Use a Grid View or PageViewer to display a gallery. The one thing you have to do while using this is Memory management.

Related

Android: How to store multiple images from recyclerview and retrieve them into imageids from the database

I have uploaded multiple images from gallery onto a recyclerview.
Now i want to store those images into the database and retrieve them in another activity where i need to place individual images into different image views having different image id's.
How should i go about doing?
Any help?
databases support BLOB type data. Convert the image to blob type and save it.
How to save images into Database

lag/slowdown when I try to display many images in a listview?

When I have so many images to display in a listview when I flow to the bottom of a picture to another there is a 1 second pause. I save the file path in the sd card in the database sqlite internal adapter and therefore in each element is taken before and after the sqlite database from SD card. How do I not have that annoying lag between an image and another? If I view the image grabbing resources such as (R.drawable.image) this does not bother you, I could make images of sd card reached as to the internal resources to the application? Perhaps accidentally memorize the pictures, I should save them for example in Android / data / com.my.app? (Images except the sd card in pictures folder). How can I improve this?
Use the Universal Image Loader for loading the images
imageLoader.displayImage(imageUri, imageView);
https://github.com/nostra13/Android-Universal-Image-Loader
This will resolve your problem.

Android how to load Image file with different extension using Picasso

This is a different situation. I want to load a image file which has stored with different extension like 'photo.xyz' instead of 'photo.jpg or photo.png' using Picasso. to avoid image from gallery i am storing image like this. Please help me is there any option to show like this.
Neither Picasso nor Android (which does the actual image decoding) cares what the file name is. It can be anything. The type of the image is always determined from the first few bytes of the actual image data.
As a small workaround you can programmatically put .nomedia file into your app folder to prevent images to be cached by mediaserver and displayed in a Gallery app.

Android: Hardcode images with paths

I am working on an a simple android application that stores objects in an array, and displays them to the user via a listview. Each object contains a photo and a single text field. For demonstration purposes, I would like to pre-populate this array with some hardcoded objects.
The trouble is that the images are typically acquired through the camera interface, and each object only stores the path to that image. I can add the hardcoded images as drawables, but then they don't have a file path. I could when the app is initialized, convert the drawables to bitmaps and save the bitmaps to the SD card, but that seems too complicated to be the correct answer...
Any ideas on the best way to get these images into file storage so that I refer to them via their URIs?
Thanks!
When you create your views in your adapter, have a ImageView in your layout and use a loader or custom AsyncTask to load the image in the background and have it update the ImageView instance once it has the data.
check the background from this on loading images from the network.
You acquire images from the camera but notice that when you do a resource chooser where mimetype = img/*, the selector just merges local camera(gallery) storage with other photo, content providers. An example of common chooser for photos is in 'Evernote' where you go to the composer view with the 2X2 grid and touch the 'attachment' icon... thats a photo chooser...
In other words , it helps to understand the general practice for managing photos and for presenting them in imageViews.
Typically, there is a lazyLoader that has an interface with args for the imgView and the URI of the image source. Under the covers on a call to 'loadImage(view, uri), the implementation checks the following:
is the bitmap already in a memCache?
the local file , that backs the bitmap, does it exist in the folder reserved for this purpose?
if none of above, go get the array of bytes for the img from across the network ( or in your case , get bytes from camera ).
Even though your question is a little different , IMO , the standard practices for images may apply and you may want to adapt one of the many libs for image presentation to your specific requirements.

Array adapter, image downloader and internal storage

Note
This question is not aiming code answers. It intend to get some ideas
for best code practices that deals with the problem proposed.
Problem
List view that is connected as usual with array adapter of countries.
country object have 2 attributes. an image url and country name. at
the very first time images will be downloaded from the url and must be
saved on the internal memory. next time images will be loaded from the
internal memory if exist. otherwise, they will be downloaded.
What is the best structure to solve this problem?
Spot lights
a bitmap object is the container that a download steam will write to.
an image in the internal will also be sit to the bitmap object before we set bitmap to the image view.
(is this point optional) a bitmap ref. should be a member of the country class.
on download complete the downloaded image may and may not still needed because it's view is no longer visible (actually it is visible
but another country owns it). is it better to check that before we set
the image bitmap. or its better to just notify data changed.
What do you think?
Use this library for image downloading
https://github.com/nostra13/Android-Universal-Image-Loader
It has tons of features, you can cache in memory or on disk, has image loading events, and a ton of more stuff.

Categories

Resources