whether to use hashmap or Cursor for checking if data available in local database
<p>I have a situation where rows are inserted into the local database after getting response from server while doing synchronization.The composite key is say key1 and key2.As such I have set them as unique constraint.But while doing synchronization second time,I may get same rows once again.So while it tries to insert these rows second time,it fails to insert because of the constraint.To reduce the database interaction I am saving the unique key as "key1-key2" in hashMap and then checking if the record is already contained in local db.As such the contain() method can be used which I guess takes less time for searching for a value(say if the number of records from server is 300)</p>

<p>Do you think that the above solution is perfect or should I loop through the cursor that retrieves key1 and key2 from database.But in this case each time we get a record we have to loop through the cursor(consider we have 300 rows in the cursor).</p>

<p>Which of the above solution should be followed or is there some better solution to this?</p>

<p>Thanks in advance</p>
