在android系统在真实设备上移动应用后的数据消失 [英] The data disappear after moving the application on a real device in android

查看:145
本文介绍了在android系统在真实设备上移动应用后的数据消失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从code,但里面还是空只创建一个表。运行模拟器时,那么我反而通过插入一个拉出来的文件和SQLite的浏览器插入数据,把它回数据/数据​​/程序包/ file.db与此解决方案,运行程序,我可以看到的信息列表之后模拟器。但在真实设备上移动应用,也看不出真实设备上的任何信息列表。我应该怎么办?

I create only a table from code but inside still empty. I instead insert data by pull a file out and insert by SQLite Browser when run the emulator then, put it back to the data/data/package_name/file.db with this solution, after run the program I can see the list of information in Emulator. But moving the application on a real device, I cannot see any list of information on a real device. How should I do?

由于我的应用程序只是将数据提供给用户,让用户无需将数据添加或编辑到数据库中。此外,数据不需要经常改变。这就是为什么我使用SQLite浏览器来插入数据。

Because my application just provide the data to user, so user has no need to add or edit data to the database. In addition the data don't need to change very often. that's why I use SQLite Browser to insert data.

我知道,有一些安全(不是根)设备限制。但是,有没有有关解决方案的任何建议。我应该如何修改我的code?

I know that there are some security constrain in (not-rooted) device. However, are there any suggestion about the solution.. How should I edit my code?

推荐答案

您可以在资源/资产/文件夹打包你的数据库,然后将其复制到/数据/数据​​/ YOUR_APP_FOLDER /数据库,如果数据库中不存在(即首先安装),或者如果它是比资产文件夹中的文件(即,更新后的APK)以上。

You can package your database in your res/assets/ folder and then copy it onto the /data/data/YOUR_APP_FOLDER/databases if the database does not exist (i.e., first install) or if it's older than the file in the assets folder (i.e., updated apk).

这帖子有一个完整的工作的例子:的http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/

This post has a full working example: http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/

这篇关于在android系统在真实设备上移动应用后的数据消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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