Hi Bert, let me take one more chance on this....
Rajesh:
The delete flag 0x8000 == 32768 which is greater than two bytes
BUT we have to write this in two bytes(as data File schema only gives us two bytes)
THEREFORE 0x8000(32768) can only be represented as -32768 in two bytes. (I don't think there is any other way to represent this number as positive number in two bytes).
THATS what the method writeShort(int x) of RandomAccessFile does. It does some bit operations and write writeShort(0x8000) as -32768.
WHEN you read using readUnsignedShort() it reads it as 32768==0x8000
Rajesh Said:
if (readShort()==0) {
valid record;
}
else if (readUnsignedShort == 0x8000) {
deleted record;
}
else {
no idea; // can someone explain ?
}
Answer to "else" Part: Database is corrupt, the schema does not allow anything else. So when you do any operation on database check if it is valid(don't read deleted or corrupted records) EXCEPT when you are adding a new record you might want to use a space of deleted record, where you have to look for deleted record (0x8000)