RMS 问题

发布于 2024-10-09 03:13:12 字数 933 浏览 6 评论 0原文

我的 RMS 有问题,我需要删除一条记录并在升级后移动该记录,有机会做到吗?我试图避免这种情况,但总而言之,我最终得到了这个:(


有没有办法将这个:转换

public void profilRmsPopulator(Form fr, ChoiceGroup hg) throws RecordStoreNotOpenException, RecordStoreException{
     int spacePos=0;

       for (int i =1; i<=rs.getNumRecords();i++){

       System.out.println("for loop\n");

  spacePos=RmsToStringDumper(i).indexOf(" ");
       System.out.println("spacePos: \n" +spacePos);

        hg.append(RmsToStringDumper(i).substring(0, spacePos),null);
           }

       fr.append(hg);

}

为 while (recordEnumeration.hasNextElement())?当然可以使用这个字符串修剪:P


好吧,也许我'我将解释我现在遇到的问题。我已经在移动设备上创建了一个应用程序,到目前为止它正在创建用户配置文件并将其写入 RMS,并且它的工作原理如下:询问用户。对于配置文件的名称和其他一些详细信息,当他/她完成后,记录的模式如下所示:配置文件的名称、型号、品牌等。然后程序会修剪记录以获取配置文件的名称并将其放入。它也像一个魅力一样工作,但真正的问题是删除,我可以删除第一条或第二条记录,但是当我放置新的[新配置文件]时,我收到如下错误:

javax.microedition。 rms.InvalidRecordIDException:查找记录时出错

I have a problem with RMS, what I need is to delete an record and move the records after level up, is there any chance to do it? I've tried to avoid this, but all in all I end up with this :(


Is there any way to convert this:

public void profilRmsPopulator(Form fr, ChoiceGroup hg) throws RecordStoreNotOpenException, RecordStoreException{
     int spacePos=0;

       for (int i =1; i<=rs.getNumRecords();i++){

       System.out.println("for loop\n");

  spacePos=RmsToStringDumper(i).indexOf(" ");
       System.out.println("spacePos: \n" +spacePos);

        hg.append(RmsToStringDumper(i).substring(0, spacePos),null);
           }

       fr.append(hg);

}

into while (recordEnumeration.hasNextElement())? Of course with this string trimming :P


ok, maybe I'll explain the problem I'm suffering now. I've created an app on mobile which as far as now is creating a user profile and writing it in a RMS, and it's working just fine. The algorithm works like this: user is asked for name of profile and some other details, when he/she is done, Data is being saved. The schema of the record looks like this: Name_of_profile, model, brand etc. Than the program trims the records to get the name_of_profile and puts it in the choiceGroup. And it also worsk like a charm, but the real problem is with deleting, I can delete first or second record, but when I put new one [ new profile ] I'm receiving error like this:

javax.microedition.rms.InvalidRecordIDException: error finding record

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

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

发布评论

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

评论(1

土豪我们做朋友吧 2024-10-16 03:13:12

我认为您的意思是您需要对记录 id 进行“重新编号”,以便删除所产生的间隙不存在,并且您有一系列整齐的 id,范围从 1 到 n(记录数)。

可以这样做,但是成本很高 - 没有记录的“更新”,只有添加/插入/删除操作。因此,您需要迭代所有记录,读取它们,删除它们并使用修改后的 id 写回它们。以正确的顺序应用更改也可能很棘手。

为什么需要消除间隙?您可以使用 RecordStore enumerateRecords 方法返回的 RecordEnumeration 来迭代整个集合,“跳过”间隙。或者,您可以使用 getRecordIDs 方法获取当前 id 集的数组。无论哪种情况,您都可以进行迭代而不会看到间隙。

I presume you mean you need to 'renumber' the record ids so that the gap created by the deletion does not exist, and you have a neat series of ids ranging from 1 up to n, the number of records.

You could do that, but it would be expensive - there is no 'update' for records, only add/insert/delete operations. So you would need to iterate over all the records, reading them, deleting them and writing them back with the modified id. Applying the changes in the right order might be tricky too.

Why do you need to eliminate the gaps? You can iterate over the complete set, 'skipping' gaps using the RecordEnumeration returned by the RecordStore enumerateRecords method. Or, you could get an array of the current set of ids using the getRecordIDs method. In either case you can iterate without seeing gaps.

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