Android提供了一些保存应用程序信息的方法。http://developer.android.com/guide/topics/data/data-storage.html
现在,我的问题是,我有一些可以与任务相媲美的结构化数据,这些数据具有类别和其他一些相关设置。所有内容都是从web服务获取的,并且必须保存以供性能和脱机使用。
在Android上使用哪个是最好的选择?我认为真正的选择是在SQLite数据库和内部存储之间。选择其中一个选项时,我对性能和实现的期望是什么?
发布于 2011-08-18 18:17:47
缓存数据的一种非常简单的方法是序列化对象并将它们保存到内部缓存中,例如:
// Example object which implements Serializable
Example example = new Example();
// Save an object
ObjectOutput out = new ObjectOutputStream(new FileOutputStream(new File(getCacheDir(),"")+"cacheFile.srl"));
out.writeObject((Example) example);
out.close();
// Load in an object
ObjectInputStream in = new ObjectInputStream(new FileInputStream(new File(new File(getCacheDir(),"")+"cacheFile.srl")));
Example example_loaded = (Example) in.readObject();
in.close();发布于 2011-08-18 18:09:24
如果您的web服务提供了XML或JSON,则只需将其保存在文件中,然后从文件中读取即可。这就像是“缓存”数据。
https://stackoverflow.com/questions/7105687
复制相似问题