博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
直接用sqlite3处理iphone的短信
阅读量:5241 次
发布时间:2019-06-14

本文共 2576 字,大约阅读时间需要 8 分钟。

由于iphone用sqlite3数据进行短信的存储。可以用sqlite3对数据库进行直接操作,清理垃圾短信。

  1. 用DiskAid连接iPhone,将 /private/var/mobile/Library/SMS/sms.db 文件下载到电脑里。
  2. 用sqlite3打开数据库文件,
    1. .table看到数据表
    2. select * from message
    3. delete from message where ROWID = xx; 提示 No such function: "read"

执行以下查询语句跳过触发器调用的read函数.欺骗一下数据库。

drop trigger insert_unread_message;drop trigger mark_message_unread;drop trigger mark_message_read;drop trigger delete_message;CREATE TRIGGER insert_unread_message AFTER INSERT ON message WHEN NOT new.flags = 2 BEGIN UPDATE msg_group SET unread_count = (SELECT unread_count FROM msg_group WHERE ROWID = new.group_id) + 1 WHERE ROWID = new.group_id; END;CREATE TRIGGER mark_message_unread AFTER UPDATE ON message WHEN old.flags = 2 AND NOT new.flags = 2 BEGIN UPDATE msg_group SET unread_count = (SELECT unread_count FROM msg_group WHERE ROWID = new.group_id) + 1 WHERE ROWID = new.group_id; END;CREATE TRIGGER mark_message_read AFTER UPDATE ON message WHEN NOT old.flags = 2 AND new.flags = 2 BEGIN UPDATE msg_group SET unread_count = (SELECT unread_count FROM msg_group WHERE ROWID = new.group_id) - 1 WHERE ROWID = new.group_id; END;CREATE TRIGGER delete_message AFTER DELETE ON message WHEN NOT old.flags = 2 BEGIN UPDATE msg_group SET unread_count = (SELECT unread_count FROM msg_group WHERE ROWID = old.group_id) - 1 WHERE ROWID = old.group_id; END;

 

就可以进行删除。

delete from message where xxxx

然后设置所有短信为已读

update msg_group set unread_count = 0

顺便整理一下

VACUUM;

还原触发器

drop trigger insert_unread_message;drop trigger mark_message_unread;drop trigger mark_message_read;drop trigger delete_message;CREATE TRIGGER delete_message AFTER DELETE ON message WHEN NOT read(old.flags) BEGIN UPDATE msg_group SET unread_count = (SELECT unread_count FROM msg_group WHERE ROWID = old.group_id) - 1 WHERE ROWID = old.group_id; END;CREATE TRIGGER insert_unread_message AFTER INSERT ON message WHEN NOT read(new.flags) BEGIN UPDATE msg_group SET unread_count = (SELECT unread_count FROM msg_group WHERE ROWID = new.group_id) + 1 WHERE ROWID = new.group_id; END;CREATE TRIGGER mark_message_read AFTER UPDATE ON message WHEN NOT read(old.flags) AND read(new.flags) BEGIN UPDATE msg_group SET unread_count = (SELECT unread_count FROM msg_group WHERE ROWID = new.group_id) - 1 WHERE ROWID = new.group_id; END;CREATE TRIGGER mark_message_unread AFTER UPDATE ON message WHEN read(old.flags) AND NOT read(new.flags) BEGIN UPDATE msg_group SET unread_count = (SELECT unread_count FROM msg_group WHERE ROWID = new.group_id) + 1 WHERE ROWID = new.group_id; END;

完成后将数据库文件传回手机。垃圾短信干净了。

转载于:https://www.cnblogs.com/wusam/p/3581824.html

你可能感兴趣的文章
数组filter()参数详解,巧用filter()数组去重
查看>>
查询项目中未被使用的js、css和图片
查看>>
Django Blog学习笔记(一)
查看>>
linux上挂载存储测试
查看>>
重建二叉树
查看>>
codeforces 659D D. Bicycle Race(水题)
查看>>
codeforces 696A A. Lorenzo Von Matterhorn(水题)
查看>>
获取全部校园网
查看>>
扯扯MySQL 5.6.19 Administrative Roles and Global Privileges
查看>>
2017-2018-1 20155220 《信息安全系统设计基础》课下实践——实现mypwd
查看>>
jquery/js不支持ie9以下版本的方法或属性
查看>>
Swift基础
查看>>
前端开发 - CSS - 上
查看>>
集成备注
查看>>
CSRF原理
查看>>
HDU 1518 Square(Dfs)
查看>>
Mysql基础3
查看>>
linux脚本定时备份数据库表(详解)
查看>>
C++中的类-------1.类的构造与析构
查看>>
Java文件编译出现 “编码 GBK 的不可映射字符”
查看>>