作者:Confach 发表于 2006-04-29 20:30 pm
版权信息:可以任意转载, 转载时请务必以超链接形式标明文章原始出处 和作者信息.
http://www.cnblogs.com/confach/articles/388976.html
第13章 应用程序间共享运行时对象
共享运行时对象
注: 当应用程序第一次访问运行时存储时,检查一个 NoClassDefFoundError.如果系统管理员通过应用程序控制限制访问运行时存储,将抛出此错误. 为获得更多信息,参看BlackBerry应用程序开发者指南 第2卷:高级 第1卷:基础.
BlackBerry设备使用一个运行时存储提供一个中心位置,在此位置上应用程序可以共享运行时对象.缺省的,仅由RIM数字签名的应用程序才可以访问运行时存储上的数据.联系RIM获得关于如何控制访问你的数据的信息.
获取运行时存储
>调用RuntimeStore.getRuntimeStore().
|
RuntimeStore store = RuntimeStore.getRuntimeStore();
|
为增加或获得运行时对象,调用RuntimeStore上的方法.
注:运行时存储不是持久的,如果BlackBerry重启,运行时存储的数据将丢失.
增加一个运行时对象
>调用RuntimeStore.put(long, String). 将一个唯一long ID和存储的对象作为参数.
|
RuntimeStore store = RuntimeStore.getRuntimeStore();
// Create an object and a unique number to identify the object.
String msg = "Some shared text";
long ID = 0x60ac754bc0867248L;
// put() throws an IllegalArgumentException if an object with the same ID exists.
try {
store.put( ID, msg );
}
catch(IllegalArgumentException e) {
// Handle exception - an object with the same ID exists.
}
|