Android。如何保护您的数据库? [英] Android. How to protect your database?

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

问题描述

您知道在Android中保护数据库的任何方法吗?



我想实现以下操作,但不知道是否可能: p>


  1. 仅限应用程式拥有者(建立并提供服务)存取资料库。

  2. 限制

  3. 有任何方法可以通过密码保护您的数据库吗?

  4. ol>

    使用sqlite3测试显示,您可以在另一个应用程序使用它时更改数据库。所以,我认为可能有一些外部应用程序可能会损坏您的数据或使用它,这是坏的。



    此外,您如何处理可能发生的数据库异常在这样的同时数据库使用期间:


    1. 向用户消息显示并关闭

    2. 继续工作

    3. 只是关闭?

    应用程序下一次?



    感谢

    解决方案

    并从列表中强制执行选项(1)。电话/系统上的每个应用程序都有自己的用户ID,并且没有应用程序可以访问任何其他应用程序的数据库文件。



    如果您想要共享您的数据与访问控制),您可以创建一个内容提供程序,然后可以由其他应用程序使用: http://developer.android.com/intl/de/reference/android/content/ContentProvider.html



    有是以上规则的一些例外:


    1. 在SDK中的模拟器中,adb shell可让您完全访问模拟手机文件系统。

    2. 在已经rooted的电话中,任何获得root权限的应用程序都可以访问任何其他应用程序的数据库文件

    基本上,您的电话号码是您的电话号码不需要担心它。 Android通常会为您预防这些问题。


    Do you know any ways to protect a database in Android?

    I would like to implement the following, but don't know whether it is possible:

    1. Limit access to the database to only the application owner (which created and serves it).
    2. Restrict or deny access to the database from all other applications during the usage session of DB owner application.
    3. Are there any ways to password protect your database?

    Tests with sqlite3 showed that you can change the database while another application uses it. So, I assume that possibly some external application can corrupt your data or use it, which is bad.

    Also, how do you propose to process a database exception that could occur during such simultaneous database usage:

    1. show to user message and close
    2. show to user message and continue working
    3. just close?

    After all this happens, how do you propose to launch application next time?

    Thanks

    解决方案

    The android system automatically implements and enforces option (1) from your list. Every application on the phone/system has its own user ID, and no application can access the database files of any other application.

    If you do want to share your data (with access controls), you can create a content provider, which can then be used by other applications: http://developer.android.com/intl/de/reference/android/content/ContentProvider.html

    There are a couple of exceptions to the rules above:

    1. In the emulator in the SDK, the adb shell gives you full access to the emulated phone's filesystem. This is not the case in a live android phone.
    2. In a phone that has been "rooted", any application that gets root permissions can then access the db files of any other application (as well as anything else) - this is the cost/risk of rooting your phone, and is the device owner's responsibility.

    Basically, you don't need to worry about it. Android will normally prevent these issues for you.

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

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