函数式编程
表中有 4 列和主键。当你插入一个新行时,你为ContentValues对象提供了值,但你为每一列做了两次:values.put(FeedReaderContract.FeedEntry.COLUMN_NAME_TITLE, newsReport.getTitle());values.put(FeedReaderContract.FeedEntry.COLUMN_NAME_CONTENT, newsReport.getContent());values.put(FeedReaderContract.FeedEntry.COLUMN_NAME_CHANNEL, newsReport.getNewsChannel());values.put(FeedReaderContract.FeedEntry.COLUMN_NAME_IMAGE, newsReport.getPic());values.put(NewsFeedProvider.newsTitle, newsReport.getTitle());values.put(NewsFeedProvider.newsContent, newsReport.getContent());values.put(NewsFeedProvider.newsChannel, newsReport.getNewsChannel());values.put(NewsFeedProvider.newsImage, newsReport.getPic()); 为什么?我怀疑其中之一:NewsFeedProvider.newsTitleNewsFeedProvider.newsContentNewsFeedProvider.newsChannelNewsFeedProvider.newsImage回报null。所以删除这些行:values.put(NewsFeedProvider.newsTitle, newsReport.getTitle());values.put(NewsFeedProvider.newsContent, newsReport.getContent());values.put(NewsFeedProvider.newsChannel, newsReport.getNewsChannel());values.put(NewsFeedProvider.newsImage, newsReport.getPic());不需要它们。列的值由前 4 行设置。