I have been learning SQLite on Android and have done some tutorials on how to use it.
There is a question that I want to ask.
Is there a way to make my app connect to my MySQL database in a remote web server of mine so that it can read data and also write data to the database?
From what I've researched, SQLite cannot be used remotely and I would need some kind of Web service in between?
It's not easy to create a connection to MySQL from Android, if it's not impossible. With that, it's also not safe if for example someone decompiles your app they have access to your whole MySQL database if you don't limit it enough.
For those reasons, you can better use a (for example) PHP webservice to which the Android application sends all their requests. An example is available at http://www.helloandroid.com/tutorials/connecting-mysql-database.
I also suggest you use Android Asynchronous Http Client so you don't have to deal with connectivity issues and AsyncTasks yourself.
You can refer to this tutorial but you do need a web-server for it.
Request mechanism
Android App ----> webserver ------> database (mysql)
Respond mechanism
Android App <---- webserver <------ database (mysql)
Android App will use JSON or other to get the data and display it
You have to use Sqlite database and web Services both. First you have to save the data in local database i.e. SQLite database and then send this data to your server using web services and vice versa.
this link for web services
and this link for SQlite will help you understand.
Thanks.
Related
I am making an android project which inserts information into mysql database via php code. I am able to do so on my local server (using xampp). I have taken a free webhosting byethost7.com domain http://hpisys.byethost7.com for using my database and php file from that server. I am able to open php page on internet and insert the information into the online database server. But via android app I am not able to insert information using the same php code. Please help me out of this.
If you are also using this data in a web project I would set up a RESTful service and get the data that way. If not I would use something like Firebase instead, as it will be much easier to set up.
Either way you will need to research those yourself. You should be able to find a lot of tutorials.
Is it possible to connect to a mysql database using android service and asynctask without using any server site scripts such as php??
My application needs to create an offline replica database, and synchronize if updated by user.
Please give suggestion and possible links, references or code.
Thanks in advance.
be aware of this :
if you connect to a remote DataBase without using a webService you will store the database login credentials inside your app. so it'll be easy to extract your login for that database and access and edit it even destroy it by decompiling your app.
I have a web application on Android and iOS which uses html and javascript for the project. I now have local values and app works fine. now I want to use a mysql database for my inputs, are there any good tutorial or sample codes on how to do that.
I'll appreciate if you can help me with this.
Thanks
For web app and mysql communication need a scripting language like php and for database you need a database like mysql there is simple tutorial fo mysql connectivity
http://www.androidhive.info/2013/12/android-populating-spinner-data-from-mysql-database/
You need to choose a language that will operate server side to manage the database of your web app, e.g. you could use PHP as a language and MYSQL as a database software (it's free and awesome), for examples you could use http://php.net/ and search how to use specific mysql commands in PHP, or use a framework like CodeIgniter which has built in functions for database management and you can view some of them here https://ellislab.com/codeigniter/user-guide/database/active_record.html, but make sure you use the whole user guide on how to use it and how to set up your database configuration properly!
EDIT. If you don't want to use PHP for the actual app then you can use it server side, i.e. use it as part of a server file which connect to database, handle data, send it back, then send it back to your remote app where you can handle it with Javascript.
I am creating an app which queries an online database. I am using a mySql db hosted on a free web server. Can I create web services on free servers? Also can I query a database from my app directly without using web services?
as RED_ has stated, you need Http POST to query your database. For the answer for free web server is Yes you can.
You can create some PHP file to execute and query specific functions Such as select and display list on your android App.
As far as i know, You are NOT able to query database directly and you need gateway to do this. what i mean gateway is some files that bridging your app and the server's db. This gateway can send and receive JSON or XML objects then your android app can consume it.
Some good tutorial to begin with:
http://www.codeproject.com/Articles/267023/Send-and-receive-json-between-android-and-php
or call webservice in android
http://androidexample.com/WEBSERVICE/index.php?view=examplecloud&scat=26
if you need more detailed description, just create another question thread.
hope this helps.
From what I understand you need a .php file on the server that you will Http post to. That will talk to the MySQL database and return the information. This may not be 100% accurate but I tried it on a small local server and it worked. You cannot directly talk to a MYSQL database from my understanding.
What else have you tried so far?
No you cant query the database from android with out some webservice or some sort of application that will be in the middle between the android application and the database .
and you can create a web service in your free host
Hope that Helps
I've created a pre-made database in SQLite for an Android app I'm developing. The app should interact and pull data from the database and display it on different 'Intents'. For now I just want to set up a local server on my Windows Computer for the database.
I was wondering what is the best way of doing so? I have little to no experience with setting up local servers or anything with regards to servers.
Thanks for any help!
There is no such thing as an SQLite "server". SQLite runs locally only through libraries. Also, Android database connections can not simply connect to anything on a server.
If you need a database on a server and an Android client to manipulate the data, you need to implement some kind of client-server architecture, for example using (RESTful) WEB services or any other client-server-communication.