I have software that connects to an SQL database. I am now working on the software on Android, using SQLite, and need to transfer the SQL database (with the data) to SQLite.
How can I do this?
One way would be to create the SQLite database on the device and download and persist the data into the local SQLite data base. A good place to read up on how to do this is in the Android docs.
Another possible solution would be to create the SQLite database at the server level and download it directly within the Android app then open it. But if you modify anything locally within the app you would need to send data back to the server to keep in sync.
Create Rest API that will fetch my SQL data in JSON format.
Now from android app access that API to get data and insert that data in in your SQLite.
or if you want to fetch it in background process use sync Adapter.
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 am trying to create application that reads users (name,position,and their blood group). I will put these info in database to be able to achieve them when I need.
do I have to use (Sqlite database) or (Sql server database)?
it's depend on your requirement but if you want stored data locally use sqlite and if you want store data on server use sqlServer
for sqlite : http://www.vogella.com/tutorials/AndroidSQLite/article.html
for SqlServer you can not connect directly,you should use an script on your server and call it from application, or use jtds
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
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
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