How can I link image on android phone to database - android

Is there some way where I can just link the images from the phone to my sqlite database? At first I thought of storing them in the phone memory in a new database but I am thinking that will blow away the space. Can anyone plzz help.

Where are the pictures? Are they just files? If so, just store the filename to them as a string? If you're talking about the images in Android's media storage, you can just store the Uri to the content provider as a string (i.e. whatever you're using to retrieve it via MediaStore.Images).

Related

What is the best way to store the image in the memory of app?

I'm using sqlite db in my app and now I would like to allow user customize the background image make them able to select one from their gallery.
Should I just store the path to image and simpy refer to it every time or should I some how transfer the image to some text and store it completely in my db? The second option prevents in case of picture being deleted from gallery. But I would like to know the most appropriate way of doing that.
SQLite has a cursor limit of 1Mb. So, you will probably not be able to store it completely in the DB, when you go to to request it will probably be truncated. Store the path to the image in the database table, and access it that way.
You wouldn't store it as text. Store it as blob to your database. In my opinion this is the way to go (if you use SQLite anyway).
If you have large images then store the path to your storage and not the image to the database.
I think it would be better to save only the path of the background, you won't be limited by the size of the image
In my opinion, the best way to save the customized background image is copy it into the internal storage (private storage) of your application. If you store only the path of the file, then file cannot be available once the user deleted that.
The official docs saying about the internal storage is:
It's always available.
Files saved here are accessible by only your app by default.
When the user uninstalls your app, the system removes all your app's files from internal storage.

Xamarin Android - where to store images locally

I am writing an app that requires the ability to pull data from a cloud database and store the data locally. I'm using SQLite to store the data when i collect it from the cloud DB, but it's knowing what to do with images.
In the cloud database, I have a URL string pointing to the image. So i now need to be able to grab that image and store it somewhere locally so that i can reference in my code (i need to be able to access it with no internet, so needs to be cached or saved somewhere).
I've done a lot of reading on this but there seems to be some contradiction and dispute in terms of the best way to efficiently store images locally and where. I assume i need to store it as a Bitmap image, but where is considered best for this?
Ideally if the app is deleted, the images should also be deleted. I'm targeting Andorid 4.3 and above only if that makes any difference.
Any pointers appreciated. Thanks.
Store them in the applicatoin package path under the files directory: /data/data/com.your.package.name/files. This directory is removed when your app is uninstalled from the device.
You can access this directory by using:
string filesPath = System.Environment.GetFolderPath (System.Environment.SpecialFolder.Personal);

Android storing rss feed data

I need some suggestion here on the Sql database approach for storing rss feed data
First : My rss feeds gives image url links which i diplay using bitmap and inputstream at runtime but now for offline purposes so as to use app when internet not available how do i load them, do i need to save complete images like whatsapp does right ? is this approach right ? if yes how to save complete images in database ? a sample code will help.
Last i want to save the complete database on sd card not in internal memory , storing data on sd card will work fine or it will create problem ? because whatsapp or many other apps stores quite a data in internal memory !! if storing on sd card is not a problem how do i store complete data on sd card ?
If your image comes from your online server, use cache then save the URL to your SQLite database together with the other data you need to access when offline.
As for the downloading and caching approach for images you can see this link:
http://theandroidcoder.com/utilities/android-image-download-and-caching
Once the image is downloaded and cached you can view it even offline. :) Or else you may want to store the whole image and save it in a specific path on your phone and access it when internet connection is not present.
As for your idea on storing in SD card. there is only one problem I can think about. When the SD card is removed, all your data is lost. You should search on how to better handle data on your phone as well as do as research on storing in external storage for this one. It's now on your end to do some research about it to further understand its risk and advantages.

Most feasible way to display images in android and ios app

i want to display around 1000+ images into an application. Which is the most effective way to store images, on device or in database ?
I am using sqlite database in my app.
Store your image on server than download it in device, save your image into sdcard as a cache or simple image. At download on single success of image store its path into your table and used in your application.
Use Lazy loading concept to load image in application. Its better to store image in sdcard rather than in database.
In android or ios dont save large images into database In sqlite or in core data it can lead to database inconsistency and the database like sqlite are not designed for saving large images.
In android use
Internal Storage or External Storage
In ios use
iOS File System
It will be better if you store the image in server. But if you dont have access to a server, then store the image path in SQLite database and have the images in sdcard. It is always a good programming practice to do like this.

Save image in SQLite database from Android

I have a question about saving images in an SQLite database location in the app.
I made an app for iOS where users can snap a photo or grab an existing one from the app that saves them in a local bank in own app, since the IOS does not have so many problems with disk space.
On Android already have code that takes the photo or use an existing one, now wanted to know how save them in SQLite database. (?)
I've been reading about and some suggest saving the image in SD card and insert into the database only the image path, but if for some reason it is excluded from the SD card will have an error in your application for the path referenced no longer exists.
What would be the ideal solution for this?
You should only keep the name of the picture in the database and store the picture on the internal storage, not on the sdcard, save them in the first place as private to your application only.
The ideal solution is to store it in the SD card. Storing in DB won't keep the user from deleting it. You'll also lose this information if the user clears the app data. All databases are deleted when the user does it.
Anyway, if you choose the SQLite solution, you can use a blob field. Remember that some versions of SQLite won't support large blob data. Check this out:
http://effbot.org/zone/sqlite-blob.htm
I also suggest this:
http://developer.android.com/training/displaying-bitmaps/cache-bitmap.html

Categories

Resources