我正在“sms.xml”文件中创建收件箱备份,收件箱中有100封邮件。
现在我的收件箱中有105个短信,现在我想在同一个文件中仅备份5个最新消息。就像存档模式一样。
我该怎么做?
答案 0 :(得分:0)
如您所知,sms表的表结构,它包含带有时间戳值的文本msg。
因此,您可以向Content提供程序查询大于表中已存在的上一个时间戳的值。
要遵循的步骤,
查询已存档的最新时间戳。
通过适当更改selection
参数
通过以下示例http://www.vogella.com/articles/AndroidSQLite/article.html,您可以在内容提供商
中使用选择参数希瓦
private static final Uri SMS_INBOX = Uri.parse("content://sms/inbox");
String last_archived_date = xxxxxxxxxxxxx;
Cursor c = getContentResolver().query(SMS_INBOX, null, "date >"+last_archived_date, null, null);
有很多方法可以保留监视器last_archived_date我更喜欢SharedPreference http://developer.android.com/reference/android/content/SharedPreferences.html