I am a newbie in android and working on an app. I will be using a database on a server but meanwhile I have created a database on xampp and followed this link to connect my app with the database. I am trying to register a user and store his details into my db. I have created 3 files in xampp/htdocs folder: Config.php , DbConnect.php and new_user.php to add a new user into the database.
I am using the
url_create_product = "http://localhost/Signup_api/new_user.php"
where Signup_api is my folder in xampp/htdocs.
I have also created a JSONParser.java file in my src folder along with main activity.
But the app shows "Creating product.." message for a few minutes and then stops.
Has anyone tried to connect android app to xampp before? Please share your experience. Is it necessary to use wamp?
use ip address instead of localhost ... Example http://locahost/xxxx/index.php will be http://192.x.x.x/..../index.php. Test on android browser it can access or not first.
Related
The web is full of content for connecting MySQL within your 'own' android app, BUT BEING NOT A APP DEVELOPER, I DON'T OWN ANY APP.
I want to add data inside MySql database through an Android phone, I can use any android app that can do so. I don't want to access any data but only write it.
Reason- I've got a website currently being operated by CPanel. I need to fetch new data all the time, reason searching a handy Android app and finding ways. Maybe android app of Cpanel can work, idk.
What've I researched- It's possible on desktop: https://www.inmotionhosting.com/support/website/databases/setting-up-a-remote-mysql-connection-in-cpanel
Before you shoot at me, i want to say that i searched and found some solutions for my problem, i tried them, but in general no one of them solve my issue.
The problem is that there are a lot of "small" answers for "small" problem, and i think that i have a "huge" problem with understanding.
After this introduction, my problem is:
I build a system that simulate an emergency center.
The center is the dynamic web project, built in java (eclipse), received emergency messages from the application and show the new data on the screen.
What i already have: a dynamic web project, with fabricated data that i created (MySql), and an android application.
What i want to be done is the connect between all parts.
I mean, i don't understand how to create the connection between the android and my web project. All i want is to send from the android a message to the MySql database and to show the new updated database.
What i already tried:
I saved the sql tables in a file (in phpMyAdmin: export->go) and uploaded it to 000webhost.com.
I tried to connect it from the eclipse, not in big success.
I tried this solution:
http://www.trustingeeks.com/connect-android-app-to-mysql-database/
and got stuck in part 4/5-too much errors in eclipse.
I tried this solution:
http://www.androidhive.info/2012/05/how-to-connect-android-with-php-mysql/
and spent half a day with configurate the ports of xampp and wamp (didn't succeed to avoid conflict).
I saw solutions that told me to upload my database to host server, other told me that my local server (xampp) is good enough. Someone told me to upload all my project, not only the sql tables.
I'm very confused...i didn't think that it will be so difficult.
So all this atemps bring me to write this post and to ask from someone to give me an organized solution, that include all i need to solve this.
Thanks in advance!!
Simply put file:
mysql-connector-java-5.1.40-bin.jar
in folder
project/WebContent/WEB-INF/lib
Hope that it helps
I have some Android apps that communicates with a central server which has a mysql database. To communicate to this data base I use two ways:
1) The one you mentioned, using a php script in the server which connects and updates the mysql database.
2) Using a webservice built in java. I publish it using Glassfish. For me after trying a bunch of possibilities, it was the easiest and fastest one to deploy. What you have to do is export your project to a .war file and upload it to your Glassfish server in the admin page, usually from "your.ip:4848". There you can easily configure where you want to publish your webservice (port number). For the communication from the Android app to the webservice I use a java library called "ksoap2".
In all cases I have my data base, the web service and the php script in the same host machine.
After a lot of days and night, trying to do complicated things, i found a very very simple solution, and i add it here for the next person that will encounter this problem.
Create a new account and database in this site: http://www.freemysqlhosting.net/
Now you have a DB on the net. I will call him new DB.
You have there an option of phpMyAdmin interface. All next instructions are refering to the phpMyAdmin interface there.
Receive the link of server, user, password etc' to your mail. save it.
Use 'export' to save your data from the old local DB in phpMyAdmin to a text file.
Copy it to SQL query in the new DB, and it will add all the data, instead of typing yourself a lot of records.
now all your old data is in the new DB, that standing on a hosting server.
In your mail, you have this message:
Hi
Your account number is: xxxxx
Your new database is now ready to use.
To connect to your database use these details
Host: xxx.freemysqlhosting.net
Database name: name
Database user: user
Database password: password
(according to your password and name, of course).
So, to connect in eclipse we will use this details:
private Connection connectToDB() throws ClassNotFoundException,SQLException
{
Connection connection = null;
Class.forName("com.mysql.jdbc.Driver");
connection = DriverManager.getConnection("jdbc:mysql://xxx.freemysqlhosting.net:3306/user","user", "password");
return connection;
}
*my db user and db name are the same, so i don't know if need actually to add here "name" or "user". so if it's not working-try to change one of them to "name".
Done. now you are connected. Try to print some data to check it.
Hope i helped.
I developed an application on Android which take user informations(SignUp) and these informations are inserted an db file like .db .After that , I made LogIn in same application , which takes information about user from .db file and decides LogIn is allright or not. Thus far , everything is allright. However as you know this application is local.I want to connect web server because when I set up my app to another phone I want to take information.Can I set up web server in my own computer to try is my app working ? How can I do that on my own computer ?
You have to configure a local server and an api to make it work.
Use any webserver, XAMP,LAMP,tomcat,ect. create a data base using the phpMyadmin from your browser and also a user name to use by your application.
Use the URL like localhost/myfolder/../api.php to get the api which interacts to our application.
for interaction with the api , you can use http post.
Use this:
Xampp include apache-webserver, mysql server, php.
http://sourceforge.net/projects/xampp/
I'm making a native android app with has some user data that I want to be stored in a database.
I'm planning to use Heroku to host it. The app should be able to retrieve it and overwrite it.
Right now, I am very confused as to how to start working on it.
There are three parts:
1)writing the actual database: right now I'm using SQlite database browser. I have created a simple table database. I have no clue how to deploy this to Heroku...
2)writing a REST API to communicate with android app on device: I gather that I should also deploy this to Heroku?
3)Connecting with the device: ??? I have no clue how this works... do I write a REST API in my native android app too?
Very confused! thanks for reading.
You should follow these steps as per my knowledge:
The database that you create should be for the device(the one that you have created using sqlitebrowser.
Create a separate database at the server side and create an api that'll perform CRUD operations using an xml or json file to reflect the data in it in the database at server
whatever operations you perform you can do them in the local database and later after checking the internet connection write the edited valueds in xml or json format and send it to your server where it'll be synced with the server database.
I'm new developing android and web apps, I would like to know if is it possible to connect a mySQL DB already hosted in a website provide by phpmyadmin plataform just creating an interface to the android app? 'cause I just want to host the DB on the DNS to acess inside the app and don't want to show any interface if someone try to acess my DNS
if possible please explain details how am I able to get this, thank you very much
you can use Mysql Database which is in hosted in your website by using Php progrmamming.
For this Read How to connect Android with PHP, MySQL.
or otherwise you just do the following.
1) create db file
2) host the db file in database.
3) download the db file to the device and you can use that db file.
Have a good luck..