Search code examples
androidandroid-contentprovider

Android, Content Provider delete method on a table doesn't work


I'm trying to download some data from a server : a list of products and associate icons. This two are in two differents services.

In the class RPCS.java {list of products}, I have :

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);
}

This work fine (k = 35).

In the 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 (doesn't work), and l = 1.

So, this two are very similary, but only one work.

Have you any idea why ?

EDIT : Found : I didn't implement the delete method in my ImageProvider (noob)


Solution

  • Thanks to zozelfelfo, I have to implement the delete method in my ImageProvider