存储在 LWUIT 中

发布于 2024-12-21 03:29:57 字数 144 浏览 4 评论 0原文

请有人给我一个如何在 LWUIT 中使用 Storage 类的小示例吗?我尝试通过模拟食谱动手实验室中使用的系统来实现,但我的应用程序不需要有多个对象,因为它位于示例中。 食谱示例允许用户添加越来越多的示例,但我只想添加一项信息。

另外,如何检索存储的信息?

Please can someone give me a small sample of how to use the Storage class in LWUIT? I have tried implementing by emulating the system used in the Recipe Hands-on-Lab, but my application does not need to have multiple objects, as it is within the sample.
Recipe sample allows user to add more and more samples, but all I want to do is add ONE entry of information.

Also how do I retrieve the info stored?

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

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

发布评论

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

评论(2

夕嗳→ 2024-12-28 03:29:57
com.sun.lwuit.io.Storage.init("MobileApplication1");
if(com.sun.lwuit.io.Storage.isInitialized()) {
    com.sun.lwuit.io.Storage.getInstance().writeObject("MobileApplication1","My first string");
    String myStr = (String)com.sun.lwuit.io.Storage.getInstance().readObject("MobileApplication1");
    System.out.println(myStr);
} else {
    System.out.println("Storage not initialized");
}

上面的代码将创建一个名称为“MobileApplication1”的存储,添加一个对象“我的第一个字符串”并读取该字符串。

com.sun.lwuit.io.Storage.init("MobileApplication1");
if(com.sun.lwuit.io.Storage.isInitialized()) {
    com.sun.lwuit.io.Storage.getInstance().writeObject("MobileApplication1","My first string");
    String myStr = (String)com.sun.lwuit.io.Storage.getInstance().readObject("MobileApplication1");
    System.out.println(myStr);
} else {
    System.out.println("Storage not initialized");
}

The above code will create a storage of name 'MobileApplication1', add an object 'My first string' and reads the string.

眉黛浅 2024-12-28 03:29:57

您也可以使用 J2ME 记录存储,并且您的记录存储将始终只有 1 条记录。

You can use J2ME record store as well and your record store will always have only 1 record.

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