【问题标题】:Android, Content Provider delete method on a table doesn't workAndroid,表上的内容提供程序删除方法不起作用
【发布时间】:2014-12-09 17:12:36
【问题描述】:

我正在尝试从服务器下载一些数据:产品列表和关联图标。这两个在两个不同的服务中。

在 RPCS.java {产品列表}类中,我有:

public void importPCR() {
    final List<PriceCollectRow> priceCollectRows = mWebServices.getPriceCollectRows(mApplicationProperties.getProperty("store_id"));
    final ContentValues[] pcrAsContentValues = pcrToContentValues(priceCollectRows);
    int k = mContext.getContentResolver().delete(PriceCollectRowContract.CONTENT_URI, null, null);
    mContext.getContentResolver().bulkInsert(PriceCollectRowContract.CONTENT_URI, pcrAsContentValues);
}

这很好 (k = 35)。

在 RIS.java {icons} 中:

public void download() {
    List<Integer> artList = new ArrayList<>();
    artList.add(101640);

    final List<Image> images = mWebServices.getImages(artList);
    final ContentValues[] imagesAsContentValues = imagesToContentValues(images);
    int m = mContext.getContentResolver().delete(ImageContract.CONTENT_URI, null, null);
    int l = mContext.getContentResolver().bulkInsert(ImageContract.CONTENT_URI, imagesAsContentValues);
}

m = 0(不起作用),l = 1。

所以,这两个非常相似,但只有一个工作。

你知道为什么吗?

编辑: 发现:我没有在我的 ImageProvider (noob) 中实现删除方法

【问题讨论】:

  • 发布您的内容提供者课程
  • 好主意,解决方案在我的 Provider 中

标签: android android-contentprovider


【解决方案1】:

感谢 zozelfelfo,我必须在我的 ImageProvider 中实现删除方法

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多