java - How can I automatically delete a file referenced by a SQLite Database item when this item gets deleted from the database (in Android)? -
context
i'm creating sqlite database manipulated content provider in android.
question
let's have following sqlite table:
_id _data ------------------------ 0 /path/to/file/0 1 /path/to/file/1
where _id
primary key , _data
url file in local file system.
what have in order automatically delete file referenced _data
column when correspondent row deleted?
p.s.: know sqlite has specific features accomplish this, i'm programming android, means of these features not available.
observations
i taking @ system mediaprovider.java
class source , noticed trigger:
db.execsql("create trigger if not exists thumbnails_cleanup delete on thumbnails " + "begin " + "select _delete_file(old._data);" + "end");
which apparently deletes file referenced thumbnails._data
when thumbnail item deleted.
i tried create similar trigger in application, didn't work. ideas why?
Comments
Post a Comment