Currently I am developing an application which displays cricket scores from an api. The api returns json data of a list of live matches, which has a unique id of every match. By passing unique id of match in url, we get entire scorecard of match. But, this doesn't return photos of the players playing. So i want to display them in an imageview along with playername, Runs, Balls, boundaries,etc.
Something like this.. What's the best way? Firebase Or something else?
You need to use libraries like Glide for loading images from any link.
And for links of images you can maintain static array of URL's of images or you may write some dynamic code by which links of profile images will be extracted from the json id's (by requesting on some generic URL using those id's) you already have so that you need not to maintain any static array.
Related
I am making an android app using picasa web album. I have implemented the code to access the images using api. but i am unable to put that images in descending order so that i can access new images at top of the grid view.
I am using url like this to access code.
https://picasaweb.google.com/data/feed/api/user/_PICASA_USER_/albumid/_ALBUM_ID_?alt=json
Please help me to get url for order(sorting)
Not so much information... But an idea will be when you read your json and create a List, use myList.add(0, picURL) instead of myList.add(picURL), that will add the URL to the first position each time, instead of adding it to the end.
I am new to android. I would like to know how to retrieve stored images from a database. No add or delete functionality. I want to retrieve already stored images from a database. Please help me achieve this.
This answers assumes that you are retrieving images from a database in another app (because you'd already now how to retrieve images from a database that you created).
If the database is within another application, you must use a content provider. This link will redirect you to the official documentation. It covers all you will need to know about content providers.
In the most basic terms ever, to use a content provider you must first ask permission. Then you query the application that stores the database rather than the database itself (note: the application you query in turn queries the database). Therefore, you must have documentation that will provide predefined methods that must be used.
Not sure what really you want.
But if you finding a simple way to store image to database, you can try base64 image, it is like a string so simple store and read it in/from database.
To display base64 image on html, use can you
<img src="data:image/gif;base64,base64_data_here"/>
Reference to more information:
To convert your image to base64
How to convert a image into Base64 string?
To convert base64 to image:
How to convert a Base64 string into a BitMap image to show it in a ImageView?
I am developing a places of interest app which will display the list of places of interest in a location.
When user chooses one, it will display more information and address etc.
How do I store all this data? Currently I am using a text file to store all the data and subsequently when user chooses a place, it will parse the text file and retrieve the necessary data for display.
Any advice on what is a better way to do this? I looked at SharedPrefs, but it is more like storing "key-value" pair and in this case I need to store a large amount of data.
I want the info to be available even when the device is offline, thus I can't download from an online server upon request.
Any other way to do this?
You may store it to XML file using XML serializer, here is very good tutorial for learning that,
http://www.ibm.com/developerworks/library/x-android/
and it can be easily parsed using Java XPath Api. Have a look at this at parsing XML files
http://www.ibm.com/developerworks/library/x-javaxpathapi/
Use SQLite
It can store large data.
It is available offline.
All your problems will be sorted out.
Hre we have a wonderful tutorial for sq-lite
http://www.vogella.com/articles/AndroidSQLite/article.html
How about a relational database?
http://developer.android.com/training/basics/data-storage/databases.html
Take a look at Serialization. If you do not need database access, you could define a class what holds every information you need. Then, you can do the following:
when you need to save the datas, you serialize your object, dumping its content to a file, for example on the SD card
when you want to load the datas, you just load the above mentioned file, and get back everything from the dumped file
I am using this method in my app to cache some datas that would need internet access, so the user can still view it, and with proper implementation, this can work very nicely.
Use database, create table and insert all the data in it. When you need the data just fire the query, and you are done.
SQLite is fine for Android.
Depending on the type of data you want to store, you could use a SQLite Database (provided with Android) if it has a normal database structure. You could Serialize your data and save it in a raw or encrypted file, making you data implement Serializable.
I am fetching a content of an Internet feed and storing it into a local database (caching). the feed does not have a tag which will tell me when a specific entry in it was created (no date tag). All it has is a title, content, url and image.
Now, I want to make this: if there is no new content on the feed, the app will load from the cache during the specific session. But if I see that there is a new content on the feed, then the app will load from the feed and all later loads (during one session) will go from the cache.
How can I detect in this specific case if there is a new content on the feed or not? Shall I do string comparison of the first X lines of both cache and remote feed? Or there is a better and proper way to do it?
Using your approach you will have to download the entries and compare them to the data stored in your cache. This pretty much renders the cache useless, as one of the things you want to prevent by using a caching mechanism is unnecessary downloads.
Are you sure that there are no header fields that you can use to check for changes? Good candidates are Last-Modified, If-Modified-Since and If-Not-Modified. See Wikipedia's list of header fields for more detailed information on these fields.
I have an Android application which talks to a public Data-API by calling URLs. The API returns XML which describes search results or detailed Data of a particular dataset.
In my Application i retrieve this data and parse it to Java Objects to display them in a ListView for example.
edit: Just to make it clearer: In my Application you can search for music Artists and get their whole discographic information. I Retrieve the list of Releases and display them in a ListView. (No problem right here, because the results of the same search request can change any minute i have to retrieve this data everytime a search request is issued).
Now i have a list with all the LPs the Beatles produced (for example). I can then click one particular LP and view the Details such as the Release Year and the Tracklist.
What i want to cache is the Details data and i'm currently thinking of which is the best way to do this. I thought of:
Retrieving the XML data once and store the XML Data in the SQLite Database (that would imply, that i have to parse the data everytime i want to access it again).
Retrieving the XML data once, parsing it once and somehow store the serialized JavaObject into the SQLite Database as ByteStream. (so all the time consuming work would be done just once).
What do you think is the best version or is there maybe another better way to achieve caching the results?
serializing an object would be quick solution but that could not be effective solution. Every a time you need to load entire object, while in this case if you are storing your data set into database then, using cursor/queries data handling will be smoother.
CursorAdapter will allow you to plug database cursor directly to list in GUI. I would suggest you to use database approach.