使用 Parse 仅在本地存储数据

Store Data locally only Using Parse

我可以使用 Parse 本地数据库仅在本地存储数据(不想将其保存在服务器上)吗? 我们之所以要使用 parse 来做到这一点,是因为相同的代码(逻辑)可以很容易地用在 IOS、Android 和其他地方。 谢谢

我不熟悉解析,但如果它有一个本地数据库,那么你当然应该能够。

或者,将其保存到文件:

String filename = "myfile";
String string = "Hello world!";
FileOutputStream outputStream;

try {
  outputStream = openFileOutput(filename, Context.MODE_PRIVATE);
  outputStream.write(string.getBytes());
  outputStream.close();
} catch (Exception e) {
  e.printStackTrace();
}

将其保存为 SQLite 数据库(我建议使用 sugar,它使它变得微不足道)。

https://satyan.github.io/sugar/

或者如果您只在应用程序打开时需要它,请使用捆绑包。

只要您固定 ParseObjects,就可以无限期地离线使用它们。

请参阅 Parse 的本地数据存储发布公告。指南和 API 的链接位于相应页面的底部:Android | iOS

您应该只使用 pinInBackground。它只会在本地保存到解析中。