JSON image to sqlite Android programming - android

I am new to Android Programming and would like to ask about JSON/sqlite. I have already parsed JSON text and store it in sqlite and then displayed the data in a listview in my app. However, I didn't parse the images in my JSON file (started with the easy part first). Now I have to do the image parsing and I have looked through many websites but still feel too confused about how to do it.
In the following link
http://www.androidbegin.com/tutorial/android-json-parse-images-and-texts-tutorial/
I have looked at how they do the image parsing but they're caching the images while I have to store the data into DB. In the link there is ImageLoader.java, MemoryCache.java, FileCachee.java,and Utils.java; these classes made me even more confused, do I need all of these for the images?
Can anyone please guide me like what steps I should follow? which classes of these do I need and which are not necessary?Or any kind of help.
Thank you in advance

To read in a single image, no you don't need all that. All you need is to read in an array of bytes (the contents of the file) and turn that into a Bitmap object. What all that is useful for is to hold lots of images at once- to make sure you don't use up too much RAM (MemoryCache), request them from the network more than once (FileChace), and to manage all of those (ImageLoader). So if you want to download lots of images its useful. For a single one its overkill.

Related

What is the best way to save images in Parse?

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

Mysql, sqlite and blob datas, what is the good practice?

Good morning!
I'm currently creating an Android app that have a list of texts and show one randomly. I would like to update the list from a server and I don't know what is the best way to do that.
I plan to use an sqlite database in order to download only the new datas.
Since each text is associated with an image, I consider using Blob in my database, but I don't know if using blob is really a good practce.
Should I store the path to the images instead?
https://www.digitalocean.com/community/tutorials/sqlite-vs-mysql-vs-postgresql-a-comparison-of-relational-database-management-systems
http://database-management-systems.findthebest.com/compare/30-53/MySQL-vs-SQLite
these two websites can give u a better idea which one to opt. !
Every aspect has been defined in these two sites. Hope i helped u there.
My suggestion:
Making use of JSON support in PostgreSQL is a benefit over other RDBM's
as it's fast.

Android, storing big number of small images linked to database

I have been asked to create a tiny android app.
In everyday work i code for .NET and I have no experience connected with Android, but as it is a really small app I guess it's going to be a good experience rather than something hard.
The core of the app would be a small database (probably XML, unless somebody suggest better solution) that would contain categories, names of the institutions assigned with each category and logo (not very high resolution I guess a single file would be <100kB) of the institution.
The database also would not be very big - I expect not more than 1000 records in total. The DB has to be totally offline and local, it cannot require Internet access when operating.
The model I assume would be to ship new version of the application when the database changes (which is not going to be very frequent).
What is the best way to deal with these requirements?
My first idea was to create an XML file that would contain the records and link to the image. The XML and all the images linked to it would be stored in single file (preferably zip) that would be stored in app resources. This is very good as it is going to be very easy to update the database.
The second idea that somebody suggested me would be to use SQLite and store images in BLOB. In general I have read that it isn't a good idea to store images in database directly, and I am afraid if it's going to be possible to meet all requirements mentioned above.
Mostly I have no idea how to update the database easily and attach it to new version of application.
Any suggestions?
I would be grateful for any response.
I wouldn't go about using XML to save your data and by no means zip anything.
I think your way of thinking is ok, but you're making things really complicated for yourself.
Seeing as you're used to .NET I suppose you're also pretty confident with SQL, so I'd suggest you have a look at how to use the built-in SQLite database in Android.
If you would go the XML route you'd have to serialize and de-serialize the XML file over and over again and then parse the XML. Ok you don't have a lot of data, but searching inside an XML file with at least 1000 nodes would be slow in comparison to the performance of a database.
Also upgrading an existing SQLite database is not that hard - Android has methods for that (onUpgrade coming from the SQLiteOpenHelper).
As to saving images I'm assuming that you won't fetch new pictures from the Internet, so it would be best just to store them in the drawable folder of your app (be mindful of different screensizes) and then reading them into an ImageView when needed. To figure out what image should go for what institution I would store either the image name of each image in the SQLite database or store the resource id for each image in the database - for instance R.drawable.myawesomepictureformyinstitution.
I know my answer is somewhat "superficial", but your question is also somewhat "broad" and hard to answer without me actually writing most of the code, and that's not my intention ;-)
Hope this helps - let me know if anything is unclear.

Android best way to retrieve images and view them from external source

I'm going to be making a wallpaper app but need some guidance on how I am going to be able to store, retrieve and view the wallpapers.
Will I need to make use of ImageView so I will be able to display the images?
I'm going to need some sort of database/website to store all of the wallpapers on. What would be the best thing to do, use a database or a website?
How would I go about retrieving the wallpapers from my chosen source?
Any help/advice would be appreciated, thanks.
A common practice is to use an rss feed of images. Then, just hook up your app to the rss feed and have it check for updates periodically.
Here is a reference on reading xml (rss) in Android:
http://www.ibm.com/developerworks/opensource/library/x-android/index.html
Good luck.
you can try aquery android library for lazy loading image. this library store images in cache memory so you not need to store it externally also it will take some time for first time loading image from web but once it load in your application then it will automatically store in cache so second time take very less time to display also its less time consuming then other lazzy loading methods..below code may help you.....
AQuery aq = new AQuery(mContext);
aq.id(R.id.image1).image("http://data.whicdn.com/images/63995806/original.jpg");
You can download library from from this link
Personally I would use a database. But the easiest option would be to use the 'res/drawable' folder in android I guess.
If you stored them on the internet and haven't got connectivity, you can't get your images, so users won't necessarily like this.
To get at them from a database you'll likely have to know some SQL or know someone who knows a bit of SQL. The advantage of storing them in a database would be that it's one neat package and it is portable.
Don't worry about using ImageView it, you just need to get the image from the source (database /filesystem etc..) and give it to the imageView

Can I use an sqlite database created for ios in android?

I would like to access the string-files stored in an sqlite database created for an ios application.
Any suggested methods to do this? I have searched all over the net but have not found anyone who has done this.
I know it is possible to convert a plist file to an xml file, but in the future the app I am working on will get all the resources (including strings) from a server.
I hope someone can help with this.
You could just include the SQLite database file as an asset in your app then use it like any other SQLite DB in Android.
You then mention that you will get resources from the server and I assume from your question that the data is currently in pLists so I think there may be 2 questions in one?
You might consider using JSON which, in many cases, is much faster than parsing XML. I recently used "Sublime Text" to convert a bunch of plists to JSON. It did a great job. v1 of my app parsed pLists. I tried SAX, DOM and the pull parser to find the quickest (SAX in this case) but, after conversion to JSON, v2 of the app is much, much faster. I haven't measured it because I don't need to. The user experience is enough. Where I previously had to use a loading progress dialog on a particularly large pList, with the new JSON parser, the UI is responsive at all times.

Categories

Resources