如何保护/检测Android设备上的数据库恢复? [英] How to protect/detect database restore on Android device?

查看:119
本文介绍了如何保护/检测Android设备上的数据库恢复?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Android的应用程序,在一个共同的方式将数据保存到SQLite数据库。随着用户与应用程序的工作,该数据被改变等,所以至今没有问题...

I have an app for Android, that saves data to sqlite database in a common way. As the user works with the application, the data is changed etc. So far no problem...

但是,当用户使用一些备份软件(如钛备份或其它),使应用程序的备份,他可以将数据恢复到过去的状态。我需要保护的应用程序从这个或检测恢复和处理它的方式。

But when the user use some back-up software (like Titanium Backup or others), make a backup of the application, he can restore the data to old state. I need the way to protect application from this or to detect the restoration and handle it.

简单的工作流程:


  1. 安装APP

  2. 与APP合作

  3. 前移APP的数据库STATE1

  4. 后备的APP(与任何备份/恢复应用程序,该设备可以扎根)

  5. 与APP合作

  6. 前移APP的数据库STATE2

  7. 恢复为APP(或只是数据)STATE1 - 这是我需要拒绝或检测上的应用程序的下一次执行点

到目前为止,我打了访问时间的检测和comparsion,但它似乎是通过不同的设备和ROM确实未可靠。

So far I played with the Access-time detection and comparsion, but it seems to be really un-reliable through different devices and ROMs.

感谢您。

推荐答案

要做到这一点,你需要保存一些状态,关闭设备,或数据中的至少外目录。最简单的方法可能是保存数据库文件的指纹在外部存储(SD卡)的一些隐藏的目录。或者,如果你的应用程序有Web登录等,为每个用户存储指纹。

To do this you need to save some state off the device, or at least outside of the data directory. The easiest way is probably to save the fingerprint of the DB file in some 'hidden' directory on external storage (SD card). Or if your app has Web login, etc. store the fingerprint for each user.

在任何情况下,用户对设备的完全控制,所以你不能prevent这个100%。您的应用需要妥善地处理在数据库中的任何改变或干脆失败,如果它检测到致命的矛盾。

In any case, the user has full control over the device so you can't prevent this 100%. Your app needs to gracefully handle any changes in the DB or simply fail if it detects a fatal inconsistency.

这篇关于如何保护/检测Android设备上的数据库恢复?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆