Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6664333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:35:56+00:00 2026-05-26T02:35:56+00:00

I use RecordStore to store my data. I know when we store data in

  • 0

I use RecordStore to store my data.

I know when we store data in RecordStore, it automatically generates a record id for each record.

But how can I set the record id by myself? Or how can I get the record id?

Because I want to use the recordstore.setRecord(..) method to update my recordstore.

But when I use RecordEnumeration to fetch RecordStore and use method nextRecordId(), it just shows odd or even ids. I mean when I have 8 records, it just prints out only odd or even records like

2 4 6 8

My code:

    handleRecord.openRecordStore(handleRecord.getRecordName());
    RecordEnumeration re;
    try {
         int rc = handleRecord.getRecordStore().getNumRecords();
         re = hrs.getRcs().enumerateRecords(null, null, true);

         while(re.hasNextElement()) {
             int rid = re.nextRecordId();
             System.out.println(rid);
         }
    } catch(Exception e) {
        System.out.println(e.toString());
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T02:35:56+00:00Added an answer on May 26, 2026 at 2:35 am

    MIDP API doesn’t have method to set record id by yourself.

    See RecordStore API documentation for explanation how this is supposed to work.

    • “Records are uniquely identified within a given record store by their recordId, which is an integer value. This recordId is used as the primary key for the records. The first record created in a record store will have recordId equal to one (1). Each subsequent record added to a RecordStore will be assigned a recordId one greater than the record added before it. That is, if two records are added to a record store, and the first has a recordId of ‘n’, the next will have a recordId of ‘n + 1’…”

    The code that iterates the store appears OK:

         re = hrs.getRcs().enumerateRecords(null, null, true);
         while(re.hasNextElement()) {
             int rid = re.nextRecordId();
             System.out.println(rid);
         }
    

    if you’re getting only odd or even record like 2-4-6… or 1-3-5… printed as a result, first thing to check is whether you somehow removed records that are “missing” – this could be done eg using RecordStore.getVersion method:

    • “Each time a record store is modified (by addRecord, setRecord, or deleteRecord methods) its version is incremented. This can be used by MIDlets to quickly tell if anything has been modified…”
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

OK, per the BB manual : Applications that use the record store can either
Use case: we have some project meta-data files which we want tracked, but are
Use OPENXML to get dt element in MSSQL 2005. How can I get xmlns:dt
use a reapeter to display data, but sometimes the data is to big to
use this website a lot but first time posting. My program creates a number
We use a data acquisition card to take readings from a device that increases
use Data::Dumper; %hash = ( Key => {test => [[testvalue, 10], [testvalue, 20]]}, Key2
use WWW::Mechanize; my $mech = WWW::Mechanize->new; $mech->get( $url ); say $mech->text; How could I
USE master GO DECLARE @DbName nvarchar(MAX) SET @DbName = N'DataBase' ALTER DATABASE @DbName SET
Use MongoDB GridFS store images and images stored directly on disk What are the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.