首页 > 解决方案 > 当我尝试在 google 的数据库教程中创建 SQL_CREATE_ENTRIES 时出现错误 ._ID undefined

问题描述

我正在尝试使用 google 使用 sqlite 文档获取数据来学习 sqllight,

但获得 _ID 未在该行中定义错误

private static final String SQL_CREATE_ENTRIES =
    "CREATE TABLE " + FeedEntry.TABLE_NAME + " (" +
    FeedEntry._ID + " INTEGER PRIMARY KEY," +
    FeedEntry.COLUMN_NAME_TITLE + " TEXT," +
    FeedEntry.COLUMN_NAME_SUBTITLE + " TEXT)";

FeedReaderContract 类

public final class FeedReaderContract {
    // To prevent someone from accidentally instantiating the contract class,
    // make the constructor private.
    private FeedReaderContract() {}

    /* Inner class that defines the table contents */
    public static class FeedEntry implements BaseColumns {
        public static final String TABLE_NAME = "entry";
        public static final String COLUMN_NAME_TITLE = "title";
        public static final String COLUMN_NAME_SUBTITLE = "subtitle";
    }
}

_ID 未在 FeedEntry 类中定义,但谷歌说通过实现 BaseColumns 接口,您的内部类可以继承一个名为 _ID 的主键字段

那么为什么_ID comming up as undefined shouldent FeedEntry 继承它呢?

标签: android

解决方案


推荐阅读