不想在卸载后丢失 Android 上的数据

发布于 2024-09-04 16:55:42 字数 384 浏览 5 评论 0原文

现在我进行试用申请。我想在 Android 中永久存储 IMEI 和其他信息。而且我不想在卸载后丢失它们。

我使用共享首选项进行了测试,但卸载后它会删除。

          SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
      SharedPreferences.Editor editor = settings.edit();
      editor.putBoolean("silentMode", true);                  

      // Commit the edits!
      editor.commit();

让我知道在哪里存储。

Now I make a trial application. I'd like to store IMEI and other info in Android permanently. And I don't want to lose them after uninstalling it.

I tested with shared preference but it deletes after un-installation.

          SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
      SharedPreferences.Editor editor = settings.edit();
      editor.putBoolean("silentMode", true);                  

      // Commit the edits!
      editor.commit();

let me know where to store.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

烟织青萝梦 2024-09-11 16:55:42

您可以按照 reflog 在他的评论中写道的方式进行操作。

如果您正在访问 IMEI,则有一个远程 Web 服务,该服务接受 IMEI 作为输入,并向您的应用程序提供诸如试用期已过期之类的信息。这样,用户在每次启动时都必须付出一些努力才能让应用程序在过期时运行。这种方法有两个问题

  • 如果用户没有互联网连接,您的应用程序将无法运行。即使您的应用程序不需要网络,如果没有数据连接,您也无法启动该应用程序。

  • 一些用户不喜欢将他们的 IMEI 发送到远程服务器的想法。 IMEI 是一个非常私密的数据,用于识别该用户,可用于各种数据分析。

You can do it the way reflog wrote in his comment.

If you are accessing the imei have a remote web service that accepts the imei as an input and supplies your app with informations like trial expired, and stuff like that. In that way the user has to go through some efforts on every start to have the application running if it is expired. There are two problems with this approach

  • Your app wont run if the user has no internet connection. Even if your app does not need network you can't start the app without a data connectin.

  • Some users dislike the idea of their imei being send away to a remote server. The imei is a very private piece of data that identifies this user and could be used for all kind data analysis.

水波映月 2024-09-11 16:55:42

SharedPreferences 与应用程序一起删除。
如果您的目标是 2.2 平台,则会专门为此目的添加一个新的“备份”API。
否则 - 您将不得不将信息存储在 SD 卡上。

SharedPreferences are removed together with the application.
If you target the 2.2 platform, a new 'backup' API is added specifically for this purpose.
Otherwise - you are stuck with storing the information on the SD Card.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文