J2me检测到应用程序的首次启动

J2me检测到应用程序的首次启动,第1张

J2me检测到应用程序的首次启动

据我所知,没有比这更简单的方法了,但这还是很容易的。

    public static boolean isFirstRun() {        RecordStore rs = null;        try { rs = RecordStore.openRecordStore("myAwesomeRecordStore", false); //check return false; //record store exists, so it's not our first run        } catch (Exception e) { //RecordStoreNotFoundException, but we need to catch others anway try {     rs = RecordStore.openRecordStore("myAwesomeRecordStore", true); //create } catch (Exception e1) {}        }        finally { if (rs != null) try {rs.closeRecordStore();} catch (Exception e) {}        }        return true; //so, record store did not exist and it was created (if no error occured (there shouldn't be any errors anyway))    }


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5008563.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-14
下一篇 2022-11-14

发表评论

登录后才能评论

评论列表(0条)

保存