android中无网络访问时将数据存储在本地

发布于 2024-11-03 18:10:31 字数 82 浏览 3 评论 0原文

我想使用 httppostrequest 发送数据库中的数据。但是,当没有网络访问时,如何在本地存储数据以及当我的应用程序接收到网络时将其发布到服务器

I want to send data in my database using httppostrequest.But when there is no network access how to store data locally and when my application receives network post it to server

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

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

发布评论

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

评论(3

燃情 2024-11-10 18:10:31

在数据库中可能是一个很好的解决方案。 记事本教程很好地介绍了如何在 Android 应用程序中使用数据库进行编程。

此外,值得花必要的时间阅读并熟悉 http://developer.android.com/guide/topics/data/data-storage.html

In a database might be a good solution. The notepad tutorial is a decent introduction to programming with databases in an Android app.

Also, it's worth spending the time necessary to read and become familiar with the topics covered in http://developer.android.com/guide/topics/data/data-storage.html

秋风の叶未落 2024-11-10 18:10:31

使用它来检查连接:

public boolean isOnline() {
 ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
 return cm.getActiveNetworkInfo().isConnectedOrConnecting();

}

关于将数据存储到 SQLite,请检查本教程:

http://p-xr.com/android-tutorial-simple-but-persistent-data-storage/

Use this to check for connection:

public boolean isOnline() {
 ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
 return cm.getActiveNetworkInfo().isConnectedOrConnecting();

}

On storing data to SQLite check this tutorial:

http://p-xr.com/android-tutorial-simple-but-persistent-data-storage/

走走停停 2024-11-10 18:10:31

我同意 Mark Mooibroek 的回复,并建议使用一些数据库助手而不是原始 SQLite,因为它需要大量样板代码。
上次我很高兴使用 Realm 数据库库。它在效率和编码时间方面都比 SQLite 更快。

I approve Mark Mooibroek response and advise to use some DB helper instead of raw SQLite, as it needs a lot of boilerplate code.
Last time I was glad with using Realm database library. It's faster than SQLite in terms of both efficiency and coding time.

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