Drats, it doesn't quite work. The database gets updated OK, but the device is working on an in-memory copy of the data. That means it doesn't see the changes. If you restart the device, it rereads the database and the selected image is used as the screensaver. Connecting and disconnecting from the also does it.
I think there is also a problem with using 2032 as the date. But, it would be better to calculate a date. My suggestion for the triggers would be:
Code:
create trigger add_screensaver
after insert on ShelfContent
for each row
when new.ShelfName = 'Screensaver'
and new.ContentId like '%screensaver%'
BEGIN
update content
set DateLastRead = datetime('now', '+1 month'), ReadStatus = '1'
where ContentID = new.ContentId
and ContentType = '6';
END;
create trigger delete_screensaver
after update of _IsDeleted
on ShelfContent
for each row
when new._IsDeleted = 'true'
and old._IsDeleted = 'false'
and old.ShelfName = 'Screensaver'
and old.ContentId like '%screensaver%'
BEGIN
update content
set DateLastRead = datetime('now', '-1 month'), ReadStatus = '2'
where ContentID = old.ContentId
and ContentType = '6';
END;
create trigger addagain_screensaver
after update of _IsDeleted
on ShelfContent
for each row
when new._IsDeleted = 'false'
and old._IsDeleted = 'true'
and new.ShelfName = 'Screensaver'
and new.ContentId like '%screensaver%'
BEGIN
update content
set DateLastRead = datetime('now', '+1 month'), ReadStatus = '1'
where ContentID = new.ContentId
and ContentType = '6';
END
With that, you would be safe to not removing the image from the shelf as the calculated timestamp will always be different.