Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Android

Rahsan Boykin
Rahsan Boykin
2,067 Points

User Data Inputs

I am new to Android and I am creating a simple app that takes User data (through a editor view and a Boolean check box). I want to save the data to an sql database (not shared pref or internal storage). I've got help creating the database but what I'm missing is the technique for capturing the user input and inserting that data into the database....any thoughts. (I know how to input the data if it were captured in an XML document)...I'm talking about the actual text inputted by the user through the activity display XML file (and view)

Thanks

2 Answers

Ben Jakuben
STAFF
Ben Jakuben
Treehouse Teacher

Hi Rahsan! Sounds like you'll want an EditText field for input (which we'll cover in the upcoming Self-Destructing App project). Put the EditText in your layout file and get it in your Activity's onCreate() method like normal, and then you can get the value that the user typed like this:

String userInput = mEditText.getText().toString();

(That toString() call is important!)

For the check, you'll want the CheckBox view, and to get its value you do the following:

boolean isChecked = mCheckBox.isChecked();

Hope this helps - stop back if you need further information!

Rahsan Boykin
Rahsan Boykin
2,067 Points

Thanks Ben....let me try this