If i will store 2 or more records how can i get index where it is stored.

Hi All,

I am adding the records in the address book and if i will search for a particlular name i will get all the records starting with that name but how can i get the address of the one of the particlar name at run time...

example: upon search button click for the name "xxx" i will get

output: xxx

x

xx

but i want to now how can i access the index of the selected name.

Thanking You

[436 byte] By [Mitesh_Jaina] at [2007-11-26 13:35:03]
# 1

I found this to be really tricky too. My work around to get the ID was to enumerate through the records ahead of time, then come back and search for those individual records so I knew what their IDs were.

My thoughts:

rs = RecordStore.openRecordStore("myRecords", true);

re = rs.enumerateRecords(myFilter, myComparator,boolean updated);

int i = 0;

int[] myRecordID;

byte[] myRecordData;

while (re.hasNextElement()){

try{

myRecordID[i] = re.nextRecordId();

}

catch (Exception e){

}

try{

myRecordData[i] = rs.getRecord(myRecordID[i]);

}

catch (Exception e){

}

i++;

}

That'll give you a nice synchronized listing of both data and ID.

ccsgraphica at 2007-7-7 22:17:34 > top of Java-index,Java Mobility Forums,Java ME Technologies...