What is good way to obtain data for a travel application - java

I have ran into a small issue with an Android App that I am currently working on.
I have a list of points of interest declared in an XML file. The POI's look like this:
<hotel>
<name>Hotel Atlas</name>
<latitude>45.612079</latitude>
<longitude>25.660756</longitude>
<thumb_url>/hotels/atlas.jpg</thumb_url>
<phone>039999999</phone>
</hotel>
The problem that I have is that there are about 200 points of interest and every time the users access the app the XML is read every time from an online location and that means high volumes of internet traffic. The XML is stored online so I can update it every time I want to add another POI and not force users to update the app. Is there any way to send this data to the app and not require to download the entire XML?
I have not yet found an optimum sollution for this and decided to ask for some opinions.
Thanks, Vlad

There are only 2 possible ways:
Either give static database with all POI or
Load data from web whenever required.
Now you can do one thing, keep static database with App. Make web call once app starts and check for the updated data if any changes you made in server database. If there is any change on server database, then update only those data to the local(static) database.
For implementing above step, you must have to pass Last Updated date to/from server. I mean whenever you make web call, you need to pass last updated date from the client, server will check for new data to be updated post this date. Server will store client date as updated date and return back to client.

Maybe it's possible to store POIs like "One POI - One file"? In this case you can easily read only new points from server

Related

Android: Best way to store large amount of sensor datas over long time

I'm fairly new to Android-Development and I got a general question about How-To:
My App gets Sensor-Data from Step-Detector (Detected steps gets added up).
Now I need to store those Steps (which will be a lot of Data).
The steps should be stored like this:
If Todays
steps are stored on per Hour basis.
Else
steps are stored on per Day basis
SharedPreferences falls out of this as it only stores KeyValues.
But can SQLite handle this? Or is there any other way?
A future feature could be to sync those data with a Server.
I mean this could end up in thousands of Entries, and the app will also support other large data sets which need to get stored in similar way.
Try using Realm noSql database for it. The point is, you can save entire database on sd card as separate file for each day and process it later. It is native and work very fast with large amount of data. You can process all your readings later on - open database, transform readings (perhaps interpolate values for older to shring data in size) and then upload it to the cloud and delete database file.
But, anyways, a database is just implementation details, consider abstracting out all your operations so you can replace db later on.
As far as I know, sqLite stores all tables in a single file, so you will need column for a date and all records will be stored in single table. Realm is more flexible for this task.
SQL Lite can be used , it will be there as long as your application exist in the device, however if you want you can use Cloud Service, Azure provides simple and easy to use App Service , which have easy tables , in which you can directly call the APIs and internally it takes care of making connection and inserting the data into table.You can use Free Tier of App Service to test the concept.

How to get only updated data from mysql

I need to get the only data which is updated, I am getting complete data which is affecting the performance. So whenever a client hit the API I want to send the only changes (updated data) from DB which is related to client.
There is a scenario just like facebook. If user goes offline at 12 o'clock for 1 hour i.e he will be get online at 1 o'clock. Now I need to send the notifications to him that which activities are done within offline time period.
I am using timestamp right now but Is their any other better option ?
I don't want to use timestamp or flag for last session ending time.
Thanks in advance
Try to use Versioning concept there u can get latest record .. or try to get latest record from database of that client.
There must be a column which might be an identification for updates, like last_modified_date or something. Apply the same in where clause and execute the query.
I am not sure but i know in mongo db oplog can be use to monitored changes in database , i guess like that mysql log can be use to do such monitoring if you can access it with your code. may be i am still not sure you can give it a try

Is checksum a good way to see if table has been modified in MySQL?

I'm currently developing an application in Java that connects to a MySQL database using JDBC, and displays records in jTable. The application is going to be run by more than one user at a time and I'm trying to implement a way to see if the table has been modified. EG if user one modifies a column such as stock level, and then user two tries to access the same record tries to change it based on level before user one interacts.
At the moment I'm storing the checksum of the table that's being displayed as a variable and when a user tries to modify a record it will do a check whether the stored checksum is the same as the one generated before the edit.
As I'm new to this I'm not sure if this a correct way to do it or not; as I have no experience in this matter.
Calculating the checksum of an entire table seems like a very heavy-handed solution and definitely something that wouldn't scale in the long term. There are multiple ways of handling this but the core theme is to do as little work as possible to ensure that you can scale as the number of users increase. Imagine implementing the checksum based solution on table with million rows continuously updated by hundreds of users!
One of the solutions (which requires minimal re-work) would be to "check" the stock name against which the value is updated. In the background, you'll fire across a query to the table to see if the data for "that particular stock" has been updated after the table was populated. If yes, you can warn the user or mark the updated cell as dirty to indicate that that value has changed. The problem here is that the query won't be fired off till the user tries to save the updated value. Or you could poll the database to avoid that but again hardly an efficient solution.
As a more robust solution, I would recommend using a database which implements native "push notifications" to all the connected clients. Redis is a NoSQL database which comes to mind for this.
Another tried and tested technique would be to forgo direct database connection and use a middleware layer like a messaging queue (e.g. RabbitMQ). Message queues enable design of systems which communicate using message. So for e.g. every update the stock value in the JTable would be sent across as a message to an "update database queue". Once the update is done, a message would be sent across to a "update notification queue" to which all clients would be connected. This will enable all of them to know that the value of a given stock has been updated and act accordingly. The advantage to this solution is that you get to keep your existing stack (Java, MySQL) and can implement notifications without polling the DB and killing it.
Checksum is a way to see if data has changed.
Anyway I would suggest you store a column "last_update_date", this column is supposed to be always updated at every update of the record.
So you juste have to store this date (precision date time) and do the check with that.
You can also add a column version number : a simple counter incremented by 1 at each update.
Note:
You can add a trigger on update for updating last_update_date, it should be 100% reliable, maybe you don't need a trigger if you control all updates.
When using in network communication:
A checksum is a count of the number of bits in a transmission unit
that is included with the unit so that the receiver can check to see
whether the same number of bits arrived. If the counts match, it's
assumed that the complete transmission was received.
So it can be translated to check 2 objects are different, your approach is correct.

Store some data on server to access without a db

I want to store a little bit of data on my server that can be accessed easily by anyone. It's for a game I am making and I want to store a few things such as:
Game version (String)
Description (Long String)
News (Array of Strings)
Changelog (Array of Strings)
etc...
I figured that making a whole database and table for this would be overkill. I would like to be able to access the information using various types of media but I at least ant it to work with PHP (web) and Java (Desktop and android). Also the data will be updated and inputted manually by only me but readable publicly so that other websites can use it if they choose. What would I use for this kind of thing?
Extra: I might eventually want to input data manually. Things such as "Players Joined" would be managed by my server and would increment it automatically.So if it can do that too that would be great.
I have decided to use a Database and access the data with MySQL. I already have one for my game so it is a good choice because of that (this means I won't be creating a whole database just for this). I will create a table that will store this data and the table will only have 1 row (ID = 0). I will access it by selecting the row with ID = 0. I will have to create other tables with news and changelogs too.
If you have a similar question to mine, check this out:
http://www.dummies.com/how-to/content/storing-data-with-php-flat-file-or-database.html
It provided some useful advice. Also look into JSON or XML and SQLite.
You might want to check out H2 database. It can run as an embedded database (just include a jar, no extra installation, etc.), is very solid and you can get up and running very quickly.

Android | SQLLite : Pre-created database updating without using SQLiteOpenHelper

My app uses a SQLite database for the information. I have a function that checks to see if the folder and database are already present, if they aren't it will go on the internet ( currently I am using dropbox to store the db file ) and download the database and store it on the sd card, then I it will open the database. The database is writable as it lets the user rate an object. I have two questions.
1.) I would love to provide updates to the database and then have my app update the database if the version number is higher and replace the existing one. I have done some research and from what I have found it is possible to store an xml or json file with the version number of and the just parse the information and if the version number is higher download the new database.
Can someone provide an example of how this is accomplished and whether it is better to use xml or json for this task?
2.) Is there a way to save the rating in the new version of the database when the new is downloaded and accessed?
Thanks
two nights ago I wrote something like that.
pack your database structure as an array in a webservice method by reading field names and field types. the structure of array is arbitrary.
call web service method and you must receive a string that represent a JSONArray object, if you sent it as json with json_encode() method in php.
read structure and make CREATE DB query string with for loops.
execute query, so you must have database.
also you can send alot of information with arrays.
introducing each part is hard, so for each part google it.
don't forget to convert field types to match SQLite types such as VARCHAR=>TEXT, smallint=>INTEGER , ...

Categories

Resources