如何存储多个List稍后发布到服务器?
我希望能够存储多个 List
,以便多个用户使用同一设备将信息输入到我的 Android 应用程序中。稍后,用户应该能够通过单击按钮将其数据发送到服务器。但这只能用于稍后上传,例如当有 wifi/网络连接时。
存储这些 List
的最佳方法是什么?
I want to be able to store multiple List<NameValuePairs>
for when multiple users enter information into my Android application using the same device. Later on, the user should then be able to send their data to the server at a click of a button. But this should only be for later upload for example when there is wifi/network connectivity.
What is the best way to go about storing these List<NameValuePairs>
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
那么,最好的选择是将数据存储在 Android 的 SQLite 数据库中:
http://developer.android.com/guide/topics/data/data-storage.html#db
作为替代方案,您可以将对象序列化到文件中,但这可能会太麻烦,如果数据是 大的。
然后,您可以拥有一个在后台运行的服务,并在可能的情况下将数据从本地数据库发送到服务器。
Well, your best bet is to store the data in Android's SQLite database:
http://developer.android.com/guide/topics/data/data-storage.html#db
As an alternative you can just serialize your objects to a file, but that might be too much of a hussle if the data is big.
Then you can have a service that runs in the background and sends data from the local db to the server when possible.
以下是您的存储选项:
http://developer.android.com/guide/topics/data/data -storage.html
我想,根据数据的类型和大小,SharedPreferences 或 SqlLite 可能对您有用。您可以使用
ContentResolver
支持数据库并实现同步 (SyncService
) 以上传到服务器。在这种情况下,当网络可达时,Android操作系统会智能地将您的数据同步到云端。Here are your storage options:
http://developer.android.com/guide/topics/data/data-storage.html
I would imagine that depending on the kind of data and size, SharedPreferences or SqlLite could be useful for you. You can back DB with a
ContentResolver
and implement sync (SyncService
) to upload to server. In this case, the Android OS will intelligently sync your data on the cloud when network is reachable.决定将所有内容保存为一长串由 & 符号分隔的名称值对,以便在发送到 php 服务器时轻松上传到数据库。
Decided to save everything as a long string of name value pairs seperated by ampersands for easy upload to database when sending to php server.