简体   繁体   English

为Android应用程序存储货币兑换数据

[英]Storing currency exchange data for android app

I'm hoping this will be a fairly basic question. 我希望这将是一个相当基本的问题。 I've been playing around with android development in the last couple days and I'm still missing some of the simple things. 在过去的几天里,我一直在玩android开发,但我仍然缺少一些简单的东西。

I'm working on an app which needs to convert between currencies. 我正在开发一个需要在货币之间转换的应用程序。 I know that I can get recent data with queries like this . 我知道,我能得到的最新数据与像查询

I want to be able to save this information and allow it to be updated on request. 我希望能够保存此信息,并允许根据要求对其进行更新。 I feel like the natural way to do this would be using an android resource file. 我觉得执行此操作的自然方法是使用android资源文件。 It would be ideal if someone could (as explicitly as possible) explain how I could make the query, save it to a resource file, and then read the conversion rates from the resource file in the future. 如果有人可以(尽可能明确地)解释我如何进行查询,将其保存到资源文件中,然后在将来从资源文件中读取转换率,那将是理想的。

I understand I could just make the request live each time the data is needed but I'd prefer to have something saved (so the rates can be used offline). 我知道我可以在每次需要数据时都使请求生效,但我希望保存一些内容(以便可以离线使用费率)。

Thanks in advance all. 预先谢谢大家。

UPDATE: 更新:

Though Vulovic's answer is correct, and I intend to use this approach in the future. 尽管Vulovic的答案是正确的,但我打算将来使用这种方法。 For now I have found it is simple to implement the SharedPreference class to store Currency:Rate data. 现在,我发现实现SharedPreference类以存储Currency:Rate数据很简单。

Ok, you need to create SQLite database. 好的,您需要创建SQLite数据库。 Here is a good tutorial: http://www.tutorialspoint.com/android/android_sqlite_database.htm 这是一个很好的教程: http : //www.tutorialspoint.com/android/android_sqlite_database.htm

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM