Web service or direct connection to the database? - android

I'm new in Android Development and I want to know which is better a web service or direct connection to the database (not local database). The app will need to do alot of things with charts and etc. There is alot of information to be pull from the database. If you can give me any tips I'll be thankful.

Best Performance is to store the data from WebService in local SQLite DB: but it would be complexer
you should ask every time you start your app, if theres new data in WebService to download and store it again.

If U have a good idea about PHP,JSON you can go for it,else u can use a Direct Conncetion

Related

Regarding Database on Android

Is it possible to store data directly to the database without having the user input something in it. I am planning on creating a school updater which updates students regarding school news and such. What confuses me is that how can I store data directly into it. Im not that good on servers so Im resorting into databases but Im confused where to start.
Thanks a lot!
Do you want to store data in a remote database? If yes, you may want to use REST-APIs/Webservices and process the data on the remoteserver.
You should not (except Databases like CouchDB) connect your device directly to any remote remote device for security reasons.
Anyway, you may create a local SQLite database on your device and synchronise the data using REST.

Best way to send data through devices? (Android)

Imagine an Android app where you create a poll, you receive a poll code, and when people insert your code, they view your poll, vote on it and you receive the data.
What would be the best way to send this data and save it temporarily? Should I have an external file? A database connection? A p2p connection or anything else?
Thank you very much in advance and sorry for the dumb question I'm completely new to Android.
An Online database will work. You can store the database locally on the phone and have it refresh every "X" amount of time. You will have to use some PHP coding and query the data from the database, sending it back to the phone. You can find a free webhost that lets you store databases here . Hope this helps. Also look into importing sqlite database libraries and mysql handlers to implement this. Tweak this example on Youtube to get webhost working and a simple login via php here

How to have a cache when there is no connection in my app?

I created a simple social app ,i'm using a Mysql database ,what i'm looking for is how to make the app work even without any connection , what i mean is how to have a cache of the data to get the the last update when the connection was here .
Thank you.
You have to have a local database. SQLite is probably your best option. It will have to mirror your main database and then allow synch operations when connections are available.

Local mySql DB for testing on Android?

I want to use mySql Database from my site to create an android app, what is the best way to do this?
I think to use my database local on my computer and after i finished to programing the app, connect to the real database.
how to export the real database? with phpMyAdmin? or another way?
Thanks a lot.
If you want to work import your current DB directly I don't think that it's a good idea. Android works only with SQLite database. Moreover you should implement Android specific logic to make it work in your app.
The best choice I think, it's access your data via HTTP from REST service on your site where you can easily communicate with MySql db.

Android - reading/writing to online mysql database

I've just written a short Android app which stores userdata in the phone-side sqlite database.
What I'd like to be able to do is to add this to an online database (I currently have a mysql database with my webhosts, but if there's any easier way then I'm open to suggestions), but it'll be subject to condition (Such as if a certain value doesn't already exist). I'd also like to be able to get data from this online database too to be added to the sqlite database on the phone.
I've had a look around and people seem to suggest using php as a go-between for that, but is that the easiest way? there aren't any mysql helper classes that could just interface directly or anything?
Newbie question I know, but the project was to teach myself how Android works so getting stuck in is the way to go..
Cheers!
Yes; using PHP is an example of an easier way to go. You need to create web services which allow you to interact between the android phone and a MySQL database. To my knowledge you can't go directly to a database hook; as you need to have something that can hook in. Also it would be a security issue if you put on each and all of your phones the connection information for your database.
Think if you had to change the host of your DB as your traffic grew large that you needed to upgrade; this would be a new update in the store and all clients would need to update this; otherwise you would be maintaining two code bases.
By using PHP you are able to create that middle level and easily interact with the DB.
Here is a quick article on creating REST PHP Web Service. Tutorial
Good Luck!

Categories

Resources