由于经常误删短信,删了之后又很难找回,所以想了一个办法,让iPhone在删除短信的时候保存到一个自建的表中。本来这个任务是几乎不可能的,但 恰恰iPhone的短信程序在设计时使用了数序库的触发器,于是不可能变为可能了,此方法只适用于已经越狱后的iPhone,之前需要安装 OpenSSH。
1. 通过OpenSSH登录到iPhone.
2. cd /var/mobile/Library/SMS 命令定位到目录
3. sqlite3 sms.db – 运行SQLite命令.
4. 执行以下SQLs,然后退出并重启。
CREATE TABLE message_backup (ROWID INTEGER, address TEXT, date INTEGER, text TEXT, flags INTEGER, replace INTEGER, svc_center TEXT, group_id INTEGER, association_id INTEGER, height INTEGER, UIFlags INTEGER, version INTEGER, subject TEXT, country TEXT, headers BLOB, recipients BLOB, read INTEGER, dateupdated DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP);
CREATE TRIGGER delete_message_but_backup AFTER DELETE ON message BEGIN INSERT INTO message_backup(ROWID, address, date, text, flags, replace, svc_center, group_id, association_id, height, UIFlags, version, subject, country, headers, recipients, read) VALUES(old.ROWID, old.address, old.date, old.text, old.flags, old.replace, old.svc_center, old.group_id, old.association_id, old.height, old.UIFlags, old.version, old.subject, old.country, old.headers, old.recipients, old.read); END;
.quit
reboot
误删短信后可以通过“SELECT * FROM message_backup”找回,还可以用 ‘.mode’和’.output’命令生成本文导出。
(Copyright 2012 Will Shen)