How can I store a RadioButton in a database?

1

I'm doing a database on a survey, and this is a multiple choice, but if I want to store the multiple choice answers, if the course is a INTEGER , the name is TEXT , what can the RadioButton be? Thanks.

I add this for someone to help me:

Hello, here I have an error in this line:

bdEncuesta usdbh =
                    new bdEncuesta(this, "DBEncuestado", null, 1);
            SQLiteDatabase db = usdbh.getWritableDatabase();

Where it says: (this, "DBEncuestado", null, 1); I have an error. It says: bdEncuesta() in bdEncuesta cannot be applied to.

This is what I have in bdEncuesta.java

 public class bdEncuesta extends SQLiteOpenHelper {

    String sqlCreate = "CREATE TABLE Encuestado (nombre TEXT, curso INTEGER, PREG2 text, preg3, TEXT, preg4 TEXT, preg5 TEXT)";

    public bdEncuesta(Context contexto, String nombre, CursorFactory factory, int version) {
        super(contexto, nombre, factory, version);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL(sqlCreate);
    }



    @Override
    public void onUpgrade(SQLiteDatabase db, int versionAnt, int versionNva) {

        db.execSQL("DROP TABLE IF EXISTS Encuestado");

        db.execSQL(sqlCreate);
    }
}
    
asked by Pablo Gonzalez 06.03.2017 в 12:42
source

1 answer

1

As @ A.Cedano says Radio Buttons have two states, marked and unchecked, this could be represented in Database as a Boolean (true or false).

But in this case if you are spending the Android SQLite Database the official documentation says:

  

SQLite does not have a separate Boolean storage class. Instead,   Boolean values are stored as integers 0 (false) and 1 (true).

So you should store the values if it is marked as 1 (true) and if it is not marked as 0 (false).

I hope it helps you.

    
answered by 06.03.2017 в 12:50