views:

654

answers:

3

Hello, im working on a simple Android app, it is much like any other simple Database app. I have 4 EditText fields where the user inputs 4 different small pieces of text. I want this text to be inserted in to my Database table in the corrects rows for my columns. I am not really sure how to go about doing this. I know onClickListener needs to be used but not sure how to use it.

A: 

What you are looking for is the glue to make it work, as you have a storage ( your database ) and the user interface. But, as you pointed out just right, your onClick actions, or more widely spoken, your whole user-interaction needs to be filled with action.

I won't give you a specific advice here as I think you should read a bit about the Model-View-Controller Pattern here, as well as about how Android handles all that stuff. A good entrypoint for gaining knowledge is, as always, Wikipedia.

Don't get me wrong, I don't mean to offend you by not answering the specific question: I just think it's more valuable for you to first learn the basics required for building great apps instead of reading a step-by-step manual!

moritz
A: 

On my phone right now, but you are correct about setting up an onClick method for, let's just say, a Submit button.

I would look at the Developers Guide on the SQLiteDatabase on ways to insert values by executing a SQL statement or check into using ContentValues to insert values when the button's pressed, both could help you out.

Also, with a fair share of knowledge on databases the Developer Guide should be all you need, but if you need further help search for related questions.

NOTE

A good practice is getting used to debugging your code using LogCat. It helps when things go astray, especially when working with databases.

Anthony Forloney
A: 

Tne Notepad Tutorial in the Android Developer Documentation takes you through creating an application which stores data from fields in an SQLite database.

You could work through this, or if you didn't want to do that it would be a good source of sample code.

Dave Webb