I'm hoping this will be a fairly basic question. I've been playing around with android development in the last couple days and I'm still missing some of the simple things.
I'm working on an app which needs to convert between currencies. I know that I can get recent data with queries like this.
I want to be able to save this information and allow it to be updated on request. I feel like the natural way to do this would be using an android resource file. It would be ideal if someone could (as explicitly as possible) explain how I could make the query, save it to a resource file, and then read the conversion rates from the resource file in the future.
I understand I could just make the request live each time the data is needed but I'd prefer to have something saved (so the rates can be used offline).
Thanks in advance all.
UPDATE:
Though Vulovic's answer is correct, and I intend to use this approach in the future. For now I have found it is simple to implement the SharedPreference class to store Currency:Rate data.
Ok, you need to create SQLite database. Here is a good tutorial: http://www.tutorialspoint.com/android/android_sqlite_database.htm
Related
I need to write app which will be to testing some data (some text and picture - about 500MB). But I want stored the data in database somewhere online (because I want to update it sometime and let application download whole package again)
I found Parse.com to store result, but I didnt find a way to store "the first seed" (big database). I need something like Google Translator (it is donwload some dictionary to use ofline and I trust that it is some kind of database too). Any idea?
Maybe the approach is wrong totally and there is a service which will be hold the data and the application synchronize his state ( internal database ) over internet. I really found nothing ... Thank everyone in advance.
Hey guys what's up? I'm making a very simple game for BlackBerry Curve 8520, and i need to get the ranking from the server. In order to get this data, the web programmers gave me php files that gets the data from the database and returns it as a dynamic xml file.
My question is:
How can i load that php file using java code? how can i pass a get parameter to that request?
how can i parse the xml retrieved from the php script?
Thanks in advance!
Francisco
You really have two problems here, and I think you should attempt to address them separately.
Problem 1 is getting the data from the Server
Problem 2 is parsing the data you get from the Server.
Both these problems have been covered extensively on this and other forums previously, so I suggest that you search here and elsewhere. Here are a few links from SO:
blackberry HttpConnection.GET
Parse XML file on BlackBerry
In addition, I recommend you review the documentation provided on the official BB site:
http://developer.blackberry.com/bbos/java/
including the following:
http://developer.blackberry.com/bbos/java/documentation/intro_networking_1984362_11.html
As you will see, the BB offers a number of methods of doing communication, in your case I would recommend the ConnectionFactory API:
http://developer.blackberry.com/bbos/java/documentation/network_api_1984363_11.html
And here is something on parsing XML:
http://supportforums.blackberry.com/t5/Java-Development/Use-the-XML-Parser/ta-p/445210
This should be enough to get you going. Please come back with specific questions if you have issues with any of this.
My question is similar to this one, though more involved.
I need to take the xml data from this link
http://eve-central.com/api/marketstat?usesystem=30000142&typeid=34&typeid=35&typeid=36&typeid=37&typeid=38&typeid=39&typeid=40&typeid=11399
and extract the sell/min and buy/max, average them, and then do math with the results.
I would like to also store the xml data so that requests on the servers do not need to be made often.
I have a spreadsheet that does what I want, I just need to emulate that in an android app.
Thanks for pointing out to the other question at stackoverflow.
My first answer is to use the same answer than on that thread, in this case employing SAXParser for Android and see what you get.
Kind regards,
I use PHP to access my database and generate an XML file online. My android app then gets that XML file, parses it, and inserts the data into a SQLite database.
This works just fine but is INSANELY slow. We have an iOS app and an Android App both doing the same thing... the android app takes 7-10 seconds every time the user wants refreshed data, while the iOS app only takes 2-3 seconds at most.
There aren't a lot of records - 30-50 on average. There is a lot of content - some large articles, and each with 2-10 photos (I'm not downloading the photos - just importing their url, size...etc)
I followed an example on how to use Sax to import my XML (supposedly the fastest way).
TLDR:
Is there a better way I can format my data to make it MUCH quicker than how I'm doing it now? CSV? Use PHP to generate SQLite Insert statements? What is the "norm" and/or "best" for this?
Edit:
The more I read, the more it sounds like the difference between JSON and XML are miniscule, and can even be faster with XML if it's large data (like articles) instead of JSON. Not sure this is correct, just details from further reading.
You should try using JSON instead of XML i think it might be a lot faster to work with that. It is supported on Android and as far as I know iOS can handle it as well.
I used to create a SQLite db file and gzip it, then unzip it on device and use that directly. (Not a good way for sure)
For later data updates I used json to transfer data. JSON can surely handle large articles, but if you prefer you can just put urls to the articles in JSON and fetch them in subsequent transfers.
Instead of using XML or JSON, look into Google's Protobuf :
https://developers.google.com/protocol-buffers/docs/overview
http://code.google.com/p/protobuf/
since you are on PHP, you will need to find an implementation that works for you, here is a list :
http://code.google.com/p/protobuf/wiki/ThirdPartyAddOns
Going forward, this will be a very nice way to transfer and marshall data around. Please let us know if this works for you.
I am collecting data from a website and trying to save it to a database (or something similar that is very accessible) rather than having a heap of files on my desktop or in a folder.
There are many pages that I need to look at (1900 to be exact). I want to save time in getting this data, and decided to make a Java program to do this.
This is basically what I am trying to do.
Visit the webpage: www.TestWebsite.com/items/0
Save the (Name, Description, Image(png)) into one array/class to a Database.
Repeat until I get up to: www.TestWebsite.com/items/1899
I want to be able to access this data offline without having to need to go online to view it.
Any ideas on how I should start. I have made a basic webpage viewer, I am just missing the step in between saving the strings and images to a database.
I appreciate any help!
Actually just did this the other day. I used jsoup to scrap the webpages I needed and wrote to my local database. awesomely easy framework for webpage parsing.
It's fairly straightforward, but you'll need to learn a little SQL if you haven't already.
You'll also have to pick a database platform - I'd suggest SQLite for such a purpose, since the data is for personal use and it's lightweight and easy to set up.
Here's a tutorial on using JDBC (Java Database Connectivity) to talk with a SQLite database: http://en.wikibooks.org/wiki/Java_JDBC_using_SQLite. It goes from setup to inserting data, so once you've completed that it should be straightforward to modify your webpage viewing code to grab the data you need and shove it into the DB.
Good luck!