What is the use of BaseColumns in Android

后端 未结 4 2125
花落未央
花落未央 2020-11-30 05:25

What is the use of implementing a class from BaseColumns in Android?

4条回答
  •  庸人自扰
    2020-11-30 05:49

    The BaseColumn interface only provides the column names _ID and _COUNT. You must still specify columns that use them when constructing tables. For example, to create a column using the column name _ID you might do the following:

    public static final String CREATE_TABLE =
        "CREATE TABLE IF NOT EXISTS " + TABLE_NAME + " ("
        + _ID + " INTEGER PRIMARY KEY, "
        + USERNAME + " TEXT NOT NULL, "
        + PASSWORD + " TEXT NOT NULL, "
        + EMAIL + " TEXT NOT NULL UNIQUE)";
    

提交回复
热议问题