I'm building an android game, and when finishing the game the user can insert his name on the highscores table.
The highscores table is a table in a SQLite DB that is stores in the device as part of the game.
What i'd like to do is to store this information online, so the user can choose between see the global highscores table or only his local highscore table. The local part his done.
But what do I need to create the global highscore table?
Create a DB online?
How to update and select it from android?
I read about webservices,I only need to maintain a table with 4 fields what is the simplest way to do this?
Which api should I use : Rest ful api would be good option or Http Client-server
Thanks in advance,
-To make global high-score table, u gonna need online database.
-To update and select record, I use php script to do that job, like api for my own app. You can use xml parsing to send and receive data. Here is some nice tutorial for android xml parsing.
http://www.ibm.com/developerworks/opensource/library/x-android/
http://p-xr.com/android-tutorial-how-to-parseread-xml-data-into-android-listview/
Hope this can help =)
To update in online data base ,you have to use webservice .
Send data(Highscore and other parameter) by appending to webservice on
finishing of of game
You can maintain table on online server, and when you post data,then it will
return allready made high score in responce.
Get responce and show it in user interface
This is the way to store data to online database ,i have developed an app that doing same thing.
Related
I plan on displaying dates and times in an android application but I am stuck on how I would implement this.
My Idea:
At the beginning of every month, a new calendar is downloaded. This information is displayed within the app and no internet connection is necessary for the rest of the app usage.
The information is in the form of an html table. How can I import this table, and display it within the App (also allowing the user to view only certain information in the table (querying the table))
Do I have to import this table into an sqlite database? or is there a less complicated way of doing this. I would like to limit the number of times the user has to access the internet, therefore it would be necessary to store the html table within the app itself.
How about save the table as an xml file? With the xml information you can query, or handle the data as array or list
Can you create a way to access your data in a more "friendly-way"? For example you could create an endpoint online where the app will send a request, download the JSON and save that in a internal database (SQLite, check this if you don't know how).
Or, the ugly way would be to parse the table in the device using Jsoup (which you tagged). Then it's the same, you should save it in a database and read the data from there.
By the way, I would not store directly the html table, because then you will need to parse it every time you need something (p.s it will be slow)
I am writing an app for a football fanclub and wanted to ask how I can display a football table in my app with the current standings, point goal difference and so on. I will create the table on my website but I don't know how to call it in my app, and respond to the changes I make online.
Now I had two ideas but I would like to know which one would be easier and how to implement them.
Should I do it with a webview that when online shows the table from the website and when offline shows a cached version?
Or should I somehow do it with a local database?
Or suggest something that would be even better/easier?
the best practice as i do, is to make a local database for this app,
then call a webservice to get information from the server that fills the web page as xml form, finally parse the xml and insert values into your database.
I have a problem with my application. I need the data from my MySQL-Database on the server. Usally I'm using HTTP-Posts, but this time I'm have to get a lot of db-Entrys. So I thought, that i'm just copying the database to the device. But here is the next problem: The Database on the device has the same structure like the db on the server, and additional 2 extra tables, to save some local data.
Finally my question is, how to get a lot of data from my database?
One extra question: is it possible/effective to use 2 local databases? So i could use 1 for local data and the other one for the server data. Then it would be possible to copy the db, but i need also an mysql-query, because i don't want to copy the whole data.
Yes, is possible to have 2 local db, and the best way to download an entire db from server is to dump the mysql db on server to a sqlite db, and so you may download the sqlite db from your mobile app.
Well choosing a database is depends on your project requirement. If your data is getting updated frequently on server and you want the display the updated data to the user. Do not copy database in mobile. Instead of it use webservices to get data from remote server.
And Yea, you can create two database in Android, nothing wrong in it. But again I would suggest that for only two tables do not create separate database.That can be merged in single database.
Summary
Frequently Updates in Data : Use MySql + Webservice
Static Data : Go for local db
I´m currently creating an android app through a form that saves data in a table with SQLite.
I need to include a function that when the client click "upload" the data in that table get on the actual table MySQL server and remove the table created by SQLite.
Anyone have any example of how to do this, if you could automate the action when the device has Internet would be perfect, thanks!
I would be very surprised if there was something that can do that out of the box. You'll need program something to extract the data from SQLite, format insert queries for MySQL and run them.
I want users to be able to get additional content from my website which means I will insert the downloaded data into the device's SQLite. I am wondering if I am approaching this the right way..
My current approach is to create a REST web service which returns data in JSON format, parse the JSON and insert it row by row into the Sqlite db on the android device.
Is this the right approach? Will it be too slow if there are many table rows to be inserted at one time? Or is there a way to download another SQlite db and merge it with the local one?
I welcome any suggestion, thank you in advance for your answer.
I works, but you absolutely need to paginate : set a limit to the number of element sent by your rest service.
Another approach would be to download the complete sqlite database file at once, but that requires some tweaks. see http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/ (it is about embeding the database from the assets, but the preparation of the database is the same.)
A last point: large amount of insert, as well as downloading data from a server, must to be done in a separate thread or asynctask, from a service (not an activity that can be interrupted), or even better from a SynchronizationAdapter, which is called by the system itself.