Store Image path in database - android-sqlite

I am making a app in which I am retrieving data from Database in List View.
I want to have different picture with each data I retrieve from database in list View.
What I am trying to do is to save my pictures in drawable folder of my app and want to save image path in database and retrieve my image from saved path.
I searched lot on internet but couldn't get appropriate solution.
Somebody please show me appropriate code.

Don't know if you already have solved this problem,
but after looking for it myself i found a solution.
what i did was use this.
i stored my images in a subfolder in "Assets" and this works like a charm,
don't know how many images it can hold in total, but i'll find out eventually i guess xD

Related

Dart (Flutter) iterate assets folder file content [duplicate]

I want to know if there is a way (with or without pubspec.yaml asset list) to read a directory where images will be stored, and create an array with all the paths to each image, so I can go through the array (say, with a FOR ) and create a gallery of photos. This with the purpose of being able to change, remove or add images from the directory without worrying about the paths being coded in assets.
I've read that I can use AssetBundle or RootBundle for this but I cant find any example doing so. Any help on this, even pointing me in a different approach, would be greatly appreciated.
Thanks!
EDIT: This got marked as a duplicate, but the question referenced as a duplicate is different in the sense that I need to scan a directory automatically , So I dont need to know any of the names of the files on the directory, I just want a way to read the directory (who's name I can know) and retrieve an array populated with the assets inside the directory.
There is (or at least used to be - beware, it's an implementation detail) an asset called AssetManifest.json. You can load that asset first, and it contains details of the actual assets.

Saving screenshot to CoreData

I'm developing an app that I want the user to be able to take a screenshot with a button (this works, but it's stored to camera roll). I have a need to keep history of these screenshots along with site name, etc.
I've been reading that it's not recommended to save binary data in a sqlite db, so I've stumbled across core data. I'm still learning, but one question that comes to mind is this. Some recommend to save the filename to coredata and then save the image to document directory. I want to read the data back into a table view controller and have the image part of the cell. Will I need to resize the image to the size I want when reading in, or will it automatically size down to what it needs?
Also, when saving to document directory, are those files accessible from the camera roll? I don't want them to be and I'd like to give the user the ability to be able to delete them with the tableviewcontroller.
Please let me know if I need to expand on anything. I'm learning Swift, so I'm sure I missed something.
You should not save it to the Documents directory.
You should instead Allow External Storage of the attribute. Core Data will take care of storing it for you. This is explained in the answer by jansenmaarten to this question.

Best way to load a lot of images from a server in iphone

I'm developing an app and one of its features is similar to twitter,so I have a table with each "tweet" and I display the user's picture too and I don't know what is the best way to load a lot of pictures. The images come from the server as an url.
My app's structure is:
1- I call to the server, and I get the response
2- I parse the response and I iterate it creating objects
3- I load that objects in the tableview's store
4- I reload the table
I thought one way is when I am creating the object, I load the image and I assign to the object's attribute. I mean, each time I create a object type "tweet" for example, I create the image calling the url with nsdata...
I dont know if that solution is correct or can be better. Can anyone give me a hand? Thanks in advance
Take a look at the SDWebImage API. It will do much of this automatically for you.

Where to store a preview of a UIDocument?

I'm working on UIDocument application and I'd like to show the user a preview of the document before he opens it. I can render that preview into an image when the document get's closed. But where should I save that image? In an other file? or is there a designated way to do this?
Right now I'm developing it without iCloud support. But I want to have a solution that would work with iCloud too. The UIDocument is a UIManagedDocument. But saving the image into the database would make it kind a pointless. Because then I have to open the document before I can get the preview.
What do you recommend here? Where to put a preview for a UIManagedDocument?
You can store your documents in your ubiquity container's Documents directory and document preview files in the container's Data directory.
If preview file names will be based on the documents names you will be able to use metadata query result to get the document names and then resolve document preview urls.
This way you could download the document previews only but not the whole document.
I don't know about UIManagedDocuments, but in case of a UIDocument I would recommend using a NSFileWrapper as file format (where the document is actually a bundled folder) and save the preview within the document, as "Preview.jpg" (or .png) inside a folder labeled "QuickLook".
This way, you'll get the preview in Finder on the Mac as well (for free).
Of course this may or may not be an ideal solution (also depending on if your document is text-only). But it might be a good hint for working with previews for UIDocuments in general.
You should save an image under (app_directory)/Library/Caches. That way iCloud won't affect your app.

iPhone: To store photo album image URL's and compare later:

As per my query from the below link, i've implemented retrieving photo album images from ALAsset Library.
Upload ALAsset URL images to the server
I get the images Asset URL's like below,
"assets-library://asset/asset.JPG?id=1000000001&ext=JPG"
"assets-library://asset/asset.JPG?id=1000000002&ext=JPG"
"assets-library://asset/asset.JPG?id=1000000003&ext=JPG"
I want to store these in a database (or) file [I don't know which is suitable for comparison for later purposes]. Next time(say,after 30 mins), i want to get again all the image URL's from Asset and compare with the previous image URL's which has stored in a DB, to find if any new images has been added in photo album or not. If any new image is been added in photo album, then i get that image in my code.
I want to know, what should i use to store the image URL strings, whether SQLite database (or) file, and next time which one should be sufficient to compare the previous data and the current data? I thought of going with creating sqlite database and store the data and compare the image URL strings with the stored data like that …. Am i thinking right to go? If yes, may i know how to store the data(image URL strings) in a sqlite database and do comparison between new image URL's and stored data?
I created a sqlite database through Firefox sqlite manager plugin and added a table. I'm not getting any samples further to go through to solve my purposes, i.e. store the image URL strings in sqlite database and do comparison between the stored image URL strings and new image URL strings which i got from Asset library.
Please help and advise.
Thank you!
yes you are going right. Use sqlite database to store URLs follow the tutorial
http://dblog.com.au/iphone-development-tutorials/iphone-sdk-tutorial-reading-data-from-a-sqlite-database/
Edit..sorry, i missed the last comment that explains what you want to do..
Here
http://developer.apple.com/library/ios/#documentation/DataManagement/Conceptual/iPhoneCoreData01/Introduction/Introduction.html
do that tutorial to learn how to set up the database and core data, you'll see how they save information - and from there just change code to suit your needs
Edit again.. after that you can use predicates to pull out info you need, and/or use string comparisons (Google "iPhone sdk compare strings") to compare to a new string.
or create an array of existing URL's and do something like
if ([myArrayOfURLS containsObject:theNewUrl]) {
[self doSomethingWithMyNewURLIGuess];
}