how to retrieve data from phpmyadmin and display in android application - java

i had used eclipse to develop an android apps that can allow user to register.
after they register successfully and go into the main page, they are able to see their own profile which consists of the details they keyed in during register. (The details will saved into phpmyadmin)
any method can retrieve those details from the database and display it on the profile page? (i am using php and java)
thanks for answering..

You can always use "Zend AmF" or "AMF PHP" for comunicating with the app, binary.
http://www.silexlabs.org/amfphp/
http://framework.zend.com/manual/1.12/en/zend.amf.html
or amf mixed with codeigniter
https://github.com/EllisLab/CodeIgniter
Then use:
- http://code.google.com/p/klio-mobile-dataservice/
to connect with your server

You need to have a server, like a Tomcat, or anyother server, to which you will post the data
The Servlet or the PHP script, will read the values, store them in database.
The Android application will get the data from another Servlet or a PHP page, using a HTTP Get request, and show it on the screen.
You can alternatively, store the keys locally in the device, using SharedPreferences, and get them in the next screen.

You have to write a php script wich parses data from your database into for example JSON-Format. If you had parsed the json you can use the JSON parser in android to show he content in your activitys.
Here is a very nice tutorial for json parsing in android:
http://www.androidhive.info/2012/01/android-json-parsing-tutorial/

Basically you have to create Web Service in PHP or Java and from there you need to get your data.
You have to create Restful API which returns data in the form of XML or JSON and you need to parse those data at android end. By this way you can get your data from PHP.
Here is the best resource which i found when i was searching for this kind of scenario. The author has explained very well in this and you will get very good idea about the scenario. Also provide sample code for reference.
Refer this link.
Hope this helps!

Related

IOS Application Fetch data fro MySql Database

I'm practicing some IOS coding in Swift 2 which consists in an app fetching information from a MySQL database.
However, I'm confused in the concept. So currently my idea of how to accomplish this is that somehow the IOS App connects to the Apache Tomcat. To be able to do this, I though about creating a Java application that connects to the MySql using JNDI. With this I fetch the data and store it in a JSON object.
However this is where I get stuck. Should I return this object to the IOS application or store it in a text file or JSON file and have the IOS application read it from there?
If I had to return the object, how can I do this? I've looked around but most examples are fetching information from an API and currently I want to do it locally.
The easiest way is to create a PHP file to connect and retrieve data from MySQL, and then you call this file by swift.
You will find a useful information in the following link :
How to make an HTTP request in Swift?

How to send data from android to java application on server

Hi I want to send data from my android app to server and store in the Mysql database. But I want to use REST method to send the data and I want to create a Java app on the server side that will show the data in table format .
I have created the android app but don't know how to upload data using REST. The data which I want to send is latitude and longitude of current location.
And after refreshing the java page new data will be viewed on the page.
Please tell me how to do this task.
Thanks in advance.
You can use some framework to communicate with a server. I think retrofit is the best choice for REST API: http://square.github.io/retrofit/
But you can try the Volley. Or the HttpUrlConnection and DefaultHttpClient in android sdk.
This is a big question that would need more space than here to cover. To get started you could try looking at the spring boot or drop wizard frameworks for creating your REST service.
Coursera also has a course programming web services that might help you get started.
Alternatively, there are services like Parse that look after the backend process for you.

htaccess and its usage to allow access of a url to android user using my application

I am a newbie for this security purpose and php files
I came to know about htaccess when i saw my files and databases are not secure.
I am filling listview in Android application from JsonArray parsing.This JsonArray is coming from Server when a specific URL is clicked on android application
There is a php file on server and there i have echoed the result .
Now the problem is with the data access .When I use that url on PC from browser ,It prints all the data on the browser.
NOw how can I give access to only those user who are using my android application.
I have heard of htaccess file but dont know how to use it and write it
Or is there any other way to secure or get rid of direct accessing from browser
You can use htaccess file but I think there better way.
.htaccess file is fine-tuning ruleset for Apache server. It can reprogram request completely. I use it normally with Static files.
But in your case dynamic php page. Which means you can pass a security session key.
When people login to your app they create session key. SSID This will be alive for some limited amount of time. like 1 hour. And every request required it.
No correct SSID means no data.

Load custom data from HTTP web page

I need to read some specific data in an HTML web page, from Android.
I wrote class that build the exact HTTP address. Now I can load the page and parse the data I want, but since bandwidth is expensive on smartphones, I would like to load just some custom data off the HTTP web page, to save memory.
Is this possible? How could I do it?
Cheers guys :)
Your alternatives are
Build a Proxy and host it on your server, which will parse the web page, and return relative data to the smart phones.
Read the response stream and once you get all the data you need stop reading. this is depended on how large the page is and where the relevant text you need is located.

What is the best way to send data from Java to PHP?

I want to access a MySQL database from Java, but remote connection is disabled by the host.
So I will send the data to PHP and then PHP will locally access the database.
The data is pretty big (about 2~4kb)
I've never done this before.
What should I do?
Probably the best way would be to write a web service in PHP that you call from Java.
Another somewhat easier way would be to use the HttpURLConnection class to simply do a POST of the data to the PHP page.
If the PHP page is publicly accessible, you'd want to make sure you have some kind of authentication mechanism in place and use HTTPS as well.
Http web-services
Sounds like your only option is to create a Web Service. You can use Apache's HttpClient in Java to create requests and have your PHP return a response that you can easily parse. Depending on what you are trying to do, an XML response might be overkill. I've used JSON in the past if I know exactly what I am getting back.
I assume the Java program will be the client. I think the simplest would be to just create a simple PHP page, POST any possible parameters to that page from Java, and return the data as a JSON structure.
There are a number of JSON tools for Java and PHP listed on JSON page: http://json.org/
You might want to have a look to Thrift:
http://incubator.apache.org/thrift/
Are you saying that you are going to run java from php, so that php has the handle to the mysql database and you will pass the data to java?
check out java php bridge

Categories

Resources