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
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 want to ask a question from my app users and get their answers but i don't know how to collect those data.
Please help me I need it.
You can use a form inside your application. And, ask users to fill that form. The forms needs to be connected to an database server. You may use 000webhost.com (free) to create your database. Just populate the table in database from the user response.
For this follow the following procedure:
1. Create a online database (000webhost.com)
2. Write php code to insert data into the database form and save that php on the file manager on server.
3. From android create a async task to execute that php.
4. Pass your parameter or user response as request attributes while executing the php.
5. php will save user's response on your server.
Now you can access that database from anywhere.
Note: This may require an internet connection in application.
Your question is much vague.
In general, app need to use HTTP POST with some standard data format as JSON/XML for communication between web server/client app.
This way client apps send/receive data in portable format across platforms &
implements UI/functionality as per platform standard e.g. Android or iOS
You could implement Google analytics in your app. Raise an event when you ask a question.
I want the users of my app to view an internet database, download some records of it into the database that is built in the app (not online db) and also to be able to upload some records to the online database.
I already have the database inside my app and my question is how can I make an online database that my android app could see, download from and upload to?
Android supports JDBC poorly - or let's be honest, not at all. Your best option is to create a Web server that wraps your database to a REST API. PHP is the most common language, while not the best, a lot of tutorials and snippets are available, so I would go with that. You'll have to wrap your database requests into HTTP requests and send it to the server.
For every query you'll plan on running, you'll have to create a PHP script that receives the HTTP parameters, builds the SQL query, and creates a structured XML or JSON response from the received data. This XML or JSON will than be sent to the Android client where you can parse it and obtain the data, do your syncing or such. I would suggest JSON, it's easier to read when debugging, consumes less bandwidth and has an easy to use parser in the Android API.
An easy lecture on PHP web service basics.
On using databases from PHP.
HTTP in Android.
JSON in Android.
Your online database should be on some server and you need to write a webservice to communicate your app to this online database(downloading and uploading purposes). your websrvice will also be hosted on some server. You then will be making webservice calls from your app to perform required modification to the online database.
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 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.