I have an Android app on the play store which uses a local SQLite DB on the device.
However, in a planned update, I want to sync the SQLite DB with an external MySQL server with the same table and database structure, through a PHP webservice.
However, in this case, I not only want to make sure the changes in my SQLite DB are reflected in my MySQL DB, I also want to make sure that the changes in my MySQL DB get reflected in the SQLite.
Would appriciate any suggestions about how to go about it.
When you call method of web service for update external MySQL server, this method can return result of this update to Android client.
please refer this link and check first two tutorial . it may solve your problem
Related
I need to make a app that adds data to local SQLite database and uploads data to a database so other people that use the app can download that data. I thought about loading SQLite database to online storage but I do not know how to do that or what the best way is.
This is one of the simple approach:
Your app <--->PHP webpage <----> sqlite (on server) --->url of SQLite to download
Your app need to connect to a web api, such as PHP, that can handle sqlite. You can perform sql operators via the api and then get the sqlite file by simply using its URL.
Tutorial
1.First create sqlite database
2.then create oracle database
Setup Apache server like xampp. After setup open php.ini. then delete ; before oci8.dll. then save.
C:xampp/htdocs create php webservice .
5.Call php webservice from android for download upload data.
If you can't I will help you
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
In my app I am having local Sqlite database and also other mySQL database saved on web (currently using localhost). I want to fetch specific values from mySQL database and that values to be updated in local Sqlite database.
In return like same some values from local Sqlite database to MySQL database on web(or localhost).
As you know it's easy for saving data in android and I did that stuff but getting problem while implementing
ANDROID-->WEB-->ANDROID interaction if you have did it before or having any idea,any links,or sample code please help me on this....
If you want to try it on localhost then the link below is good.
http://www.androidhive.info/2012/05/how-to-connect-android-with-php-mysql/
Mechanism you are trying to achieve like Android -> Web -> Android, can be achieved and explained here check it.
is it possible to connecct, or to copy the data from mysql to sqlite? I just need to store the data from mysql to sqlite.
I used mysql because im working on an online app in android and for updating puposes. i want to copy the data from mysql to sqlite so my android app will still run even there is no internet and because of that sqlite database.
please help. thanks
If you want to connect your application with my sql server, you can use some rest service to connect with database, and return results to the calling application.
Check examples of creating, consuming rest php service by following link:
http://www.androidhive.info/2012/01/android-login-and-registration-with-php-mysql-and-sqlite/
http://www.androidhive.info/2012/05/how-to-connect-android-with-php-mysql/
http://www.helloandroid.com/tutorials/connecting-mysql-database
By these methods you can fetch data from a mysql server, further to create and perform database operation on a device database use following link:
http://www.devx.com/wireless/Article/40842
We want to get the remote database data into local database first and then we want to access the local database. Can you please suggest us how to approach for this with sample code. Our remote database is MSSQL Server.
Have the app query the remote server, return the data from MSSQL to android code via JSON, insert into SQLite.
Edit: type MySQL to MSSQL
Get desired data from mysql ...in the form of xml from server. Parse that xml in android and fill desired java beans inside collection. then write state of object's in collection to sqlite dataabase.
I would suggest next time providing some code that indicates at least that you attempted to connect to your database first, and then if you run into trouble, someone here may be able to help. As opposed to just asking for sample code.
If you're talking about replication, I'm not sure this is possible from SQL Server to SQLite, otherwise, the answer to your question is simple, you would connect to your SQL Server database probably through some sort of exposed API, retrieve the data, parse it, and update your local SQLite Database accordingly.
Here's a link to a tutorial that covers connecting to local databases: NotePad Tutorial