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.
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.
I have a script in java that works like a crawler and saves data in MySql DB. What i want to do is build a Mobile App(Andriod/ios) which will connect to mysql database retrieve results and just show it to the user.
What is the best approach to this ? I tried to use Flex UI with PHP as my server client but was hoping to know if there is a better solution ?
The fastest would be to make android fetch a page in XML, typically on the server and display its contents(If displaying contets is your desired result).
else
You need to implement a script on your server, your POST interacts with that script and inturn that script works with your database.
A typical scenario will be:
Java HTTP POST ~~~> PHP ~~~~> MySql.
PHP will as well help you encode the result in JSON and post it back to your client.
Try using jdbc or jtds library to connect android app with mysql
I used jdts library for connecting mssql db using android app.
http://jtds.sourceforge.net
For mysql jdbc might work
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.
I have experience building android applications but now I would like to start building applications that interact with some sort of web database to push and pull data.
What type of database should i set up on a remote server for my application to interact with? From what i understand I need a database on the remote server and some service that my android app can communicate with?
What can i read that will clear up how this works and how i can get started?
The easiest (and often most flexible) combination in my opinion is PHP and MySQL. PHP as the scripting language which is called (via http) from the app, and handles all the database access. MySQL as the database. PostgreSQL is also an option for the database, of course. And if you have access to .NET, JSP or something like that, that's also an option. But a web server with Apache, PHP and MySQL is free, powerful and easy to maintain, and most/many web hosts have them.
The way it works (which is the same no matter what kind of webbased services/servers you chose), is this:
- The database is installed on the server
- You have a web area (on the web server) which has access to the database (this is how it will be with a typical web hotel solution)
- You place your scripts (f.ex. PHP) in the web area
- The web scripts access the databse, with functions for fetching and/or storing information
- Your app uses httpclient or something similar to send http GET or POST requests to the PHP scripts, either sending information or asking for information, or both
It's also quite possible to write database access code directly in your app (this is very easy in Java and C#, compared to languages like C og C++). However, most hosts don't allow remote access to their database servers, so you'd most likely have to set up a database server yourself. Also, accessing the database server directly is a security risk, and I wouldn't recommend it.
As to what you can read, there's lots and lots of tutorials, howtos and concrete examples on the net. Search for "php access mysql databse", f.ex., for ideas on how to write php scripts that handles the database transaction(s). If you have a more detailed decription, I might be able to point you to something more specific.
I strongly suggest adding web service layer between your application and database, using i.e. JSON or XML. Exposing DB directly ma be security risk and is rarely the way to go.
I am trying to develop a real-time Android application where all contents are stored in server. So, they are available whenever a connection to Internet is available. Also, the application provides communication between users and conversations are stored in the server as well. Nothing is locally stored.
However, I am still cannot decide which database type I can use. I intended to use SQLite but I am not sure if I can really use it or not.
Could you please guide me to the proper database type to my application.
Appreciate your time and efforts.
As its upto you which database you use.
you may Install Lamp (For Linux) or WAMP(for window) . This is a nice database tool and very easy to handle and easy linked with PHP for various database function
I recently developed something similar to what you are talking about and here is what I would suggest you to go for.
Use SQL server to manage the data on your desktop and create a web-service in .Net on Visual Studio.
(Note that as others have already mentioned, it really does not matter what is the database you are using in your server end, because eventually the data is going to come to the Android application from the server in form of either xml or json in the web-service., regardless of what database you are using. So it is totally your wish which database you want to use.)
Then connect to the web-service in your application and set/get data from the remote Database, using SOAP.
Link on how to make a web-service in .NET (does not include the implementation in Android).
Links on how to connect your service with Android : this, this and this.