Android Question Radio Button

vinzpogi

Member
I have this code here that I got from the User's Guide(SQLLiteLight1). The code is for the Add Button. My database is like this

ID | firstname | middlename | lastname | gender | username | password | usertype
1 a b c Male admin admin Admin

Now i have two radio buttons, rb1 = Male, rb2 = Female(not shown in the pic cos i dont know the code for it). How can i get the data from the radio button so that i can get the gender?How do i call them?
 

Attachments

  • bPNG.PNG
    bPNG.PNG
    32.2 KB · Views: 431

vinzpogi

Member
Got the idea for the radio button now. My problem now is that when i add something in the database, it doesn't show up in the database, but when i type the username and password that i registered, it works. Here's a piece of my code.
 

Attachments

  • c.PNG
    c.PNG
    46.4 KB · Views: 287
Last edited:
Upvote 0

afields

Member
Licensed User
hello vinzpogi! i'll try to help you....
so after knowing the way the radio button responds you've got a problem with your database.
you must remember that there are a 2 variants of insert sql command:
the first:
INSERT INTO <table name> values (v1,v2,v3,.....) like your's.
with that SQL is waiting to see an equivalence between the values that you pass and the types and columns that the table has.
so with your insert command you have to pass 8 values for the table fields.
the second:
INSERT INTO <table name> columns(c1,c2,c3) values (v1,v2,v3)
this insert variant tells SQL that you're going to insert a new row but only have values for columns c1,c2,c3 which by the way would be better in your case ...
INSERT INTO adminclient (firstName,MidleName,Lastnane,gender,...) values (?,?,....)
here you do not have to put null in columns that you have not values which seem to be the case of id(?)

3 more remarks:
- first if you have a table then each row will have diferent values from the others... however in each row that you have
in a relational database ( which is quite the case of sqlite) then you will have a value from a column or columns that identify
that row. the worse case is where all columns must be present the better where only one column do the job. so viewing your table i would say that id field would do that. so when you make a select to a table you can only use that value because the row will be found.
in the first sql you would not need the others fields to select that particulary row.
- assuming that the field id identify each row then in insert command you must fill that column with a value ( that of course do not exists in that column all over the rows)
which seem not your case ( you've passed a null to that field)
- with sqlite you can declare a column as rowid ( that is that column will be filled by a unique number automaticly each time a row is inserted, which leave us to my first remark. however the id field that you have is not of thst type!

for more information visit please https://sqlite.org/lang_createtable.html

i hope that these few lines will help you
regards
 
Upvote 0
Top