android - Deleted file resurrects after ACTION_MEDIA_SCANNER_SCAN_FILE intent -
i have delete image in application. when use file.delete
method (returns true, mean deleted), file deleted on file system, it's visible in gallery. delete gallery use sending of action_media_scanner_scan_file
intent or calling mediascannerconnection.scanfile
.
after strange thing happens: deleted file resurrects , returns in file.listfiles
method.
how delete file both filesystem , gallery?
delete database:
import android.provider.mediastore; import android.content.context; import android.content.contentresolver; // if calling method activity pass context parameter public void deletefromdatabase(context context, file file) { uri contenturi = mediastore.images.media.getcontenturi("external"); contentresolver resolver = context.getcontentresolver(); int result = resolver.delete(contenturi, mediastore.images.imagecolumns.data + " ?", new string[]{file.getpath()}); if(result > 0){ // success } else { // fail or item not exists in database } }
Comments
Post a Comment