Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android

How to login to a website programmaticaly through an android app and receive data

I want to login in to a website ([this one to be exact][https://www.beaconschool.org/portal/login.php]) and than receive user specific information after the user logs in. I am relatively new to android and new to coding in general and have experimented with android and have a ui with text boxes and a login button. I have so far using httpget and httpurl been able to get a response of the pages source code. But interacting with other websites through an android application confuses me and I wondered if anyone could get me on the right track here. Thank you in advance.

13 Answers

Hey Lincoln,

Firstly, I have never done Android development, so I am not 100% sure on this, but I see no-one else was replying so I thought I would.

You might want to take a look at MySQL. The link to that website isn't working, but I would take a stab at the PHP form sending information to a MySQL database where it is stored.

You should be able to query this information in your Android application using MySQL.

I hope you get a more detailed and accurate answer soon, but someone might be able to say whether I am close or not :P

Good Luck :D

No problem, if you don't know what I mean by something, just ask :D

Hi Lincoln,

You can do this without having access to the source code of the website. What you would need, is the username, password and host of the Database that stores the information for the website. You also need access to the Database via phpMyAdmin or a similar program as you will need to know database table names and column names in order to query information in the database in your application.

Please make sure that you have permission to be doing this from whoever owns that website obviously.

You do not need access to the website source code for this information.

Hope this answers a few questions.

Hi again Lincoln,

Your application will need to connect to the database in order to query it. This connection usually requires a 'config' that consists of the database host, username and password. Unfortunately this information is required to be able to query the database, otherwise anyone could query your database.

Let me just clarify:

  • You are trying to query database information created on a website from an Android application?
  • Is the website currently sending and receiving data to and from a database?

Hi Lincoln, I don't see how your project is going to work without full access to the database :D

As I do not know the situation you are in regarding the website, it is hard to comment, but I will wait until Monday and listen to what you come up with.

Thank you for the response, I will look into this. Anything helps :D

Will I be able to do all this even if I don't have direct access to the full source code of the website?

Weird repeat post, ignore

Thank you for the reply. Sorry I should've written that as well, I won't be able to see any of the usernames or passwords. But I think I may be able to get access to the database. I will have to ask the website supervisor if this is possible. Also here is a link (if this helps you at all) that should work for the website. Note the Login panel on the left side of the window.

http://www.beaconschool.org

So I talked with the guy who is in charge of the website side of things. He said there is a database, but on monday we would talk more about how limited my access is to that database. I will have more information for you Monday if your still interested in my problem. Sorry I can't be more helpful, but anything web related it completely new to me.

yeah its very weird, the person who is developing the iOS version of the app if having the same problems as me. Were going to try to work something out with the guy who is in charge of the website, thanks for all the help will give an update (at the earliest, make take longer) monday.

Sorry for lack of an update, but the guy who runs the website has been "busy" lately. Will have an update soon I promise :D

I finally was able to talk to the guy and we concluded that using a servlet was the best way to go.