Hey, my buddy.
1) Does this mean that we should use only DataInputStream and Output streams? Can I not use RandomAccessFile (since it is quite easy to implement?).
Partner, if you look at the DataInputStream class API, you'll see that it implements the DataInput interface; the DataOutputStream class implements the DataOutput interface and the RandomAccessFile class implements both of them. So yes, you can use RandomAccessFile class too as well.
2) If I have to use the DataInputStream and DataOutputStream then does someone has samples on how to read and write data to same file using two different streams please?
You can use the RandomAccessFile class
Just a curiosity, here's what I did: when my application starts, I read all the database file and load all records to a HashMap, where the record number is the key and the Room object (a class with the same structure as the database, without the record number) is the value. And this is what I control throughout the application. When the application finishes, I write all records back to the database file. Since I "may assume that at any moment, at most one program is accessing the database file", and the number of records is not big, then I thought this would be the simplest approach. So I deal with the physical .db file only 2 times: when the application starts, and when it finishes.
[ November 26, 2008: Message edited by: Roberto Perillo ]