Question

I am not able to put my question in proper order.
Let me expalin what I am trying to achieve.
I am developing Android App which used local database which I put in Asset folder.
Database is installed only once while installing app
later I copy it from asset to data folder and do all my readonly query operation.
It works all fine.
Now my problem is that database will be updated often weekly basis.
What is the best way so that Instead of updating entire app everytimne to update database i was thinking
If database version is updated then app should download new database from internet(I dont know how to achieve that) and use that to for the query operation.

Exetending to that is it possible to update database if user insert something in db
In my case user will give ratings and comments which will be updated in db

As this is my first android app.I am totaly clueless how to acheieve it. i would like to get any inputs on my problem. :)

Was it helpful?

Solution

If your database is updated on weekly basis then it will be easy for you to put your database online. You can connect to MySQL server using PHP scripts. There are many resources available online. Here are some:

Connect MySQL with Android

how-to-connect-android-with-php-mysql

These are basic tutorials. You can change your logic based on your requirements.

Hope it helps.

OTHER TIPS

Keeping your database in assets folder would be a permanent thing. If your database is such that it is necessary to update it,i suggest you use an online database,i mean keep your database in an online server. Now when you want to perform any CRUD operations,you can do it by connecting to an mySQL database using php. Hope this helps!

This looks to me like a very strange approach, why not load from the web only the changed data in JSON, xml or any other formats and run a db update according to the changed data?

Edit: answer to your question in the comment:

I guess you should learn some sql first and some serveside language (my language of choice is python, but many would choose ruby, don't go php..) and then find the right software architecture. either using REST api exposing an online db, and use the data to sql UPDATE the local db once in a while or use it directly in the app (offloading more work to the server, but paying in latency). you could also use mongodb (a NOSQL db) in the server side and query directly with REST. or just load a JSON with all the data you need, once a week and use it as a kind of a local db instead of sqlite. no short answer or short way to answer your question. you should learn different technologies, and decide which is the correct way for your specific usecase. but any technology stack would probably include somekind of:

  1. server side db (and perhaps some logic)
  2. a way to expose the db and (REST? websockets? file downloads?) query new data from the server and update it with new data.
  3. security, authorization, authentication etc level to protect the server db and logic
  4. app local db (sqllite, just an object containing data,local static files any other way), can be very minimal and resides in memory and can be the whole app.

  5. the app logic, views etc including how the app queries the local/remote db, initiate the connection between the local and remote db

  6. software tests - so It won't break on refactoring
  7. local and remote debuging toolchain
  8. some kine of code repo management (Git is hot right now, but always the best choice)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top