Browse Source

made all the methods in the database helper synchronized

Alexander Brakowski 10 years ago
parent
commit
d6ad3c5b10

+ 45 - 45
src/de/tudarmstadt/informatik/hostage/persistence/HostageDBOpenHelper.java

@@ -233,7 +233,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
 	 * @return True if an attack has been recorded in a network with the given
 	 *         BSSID, else false.
 	 */
-	public boolean bssidSeen(String BSSID) {
+	public synchronized boolean bssidSeen(String BSSID) {
 		String countQuery = "SELECT  * FROM " + NetworkEntry.TABLE_NAME + " WHERE " + NetworkEntry.COLUMN_NAME_BSSID + " = ?";
 		SQLiteDatabase db = this.getReadableDatabase();
 		Cursor cursor = db.rawQuery(countQuery, new String[] {BSSID});
@@ -256,7 +256,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
 	 * @return True if an attack on the given protocol has been recorded in a
 	 *         network with the given BSSID, else false.
 	 */
-	public boolean bssidSeen(String protocol, String BSSID) {
+	public synchronized boolean bssidSeen(String protocol, String BSSID) {
 		if(BSSID == null || protocol == null){
 			return false;
 		}
@@ -270,7 +270,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
 		return result > 0;
 	}
 	
-	public int numBssidSeen(String BSSID) {
+	public synchronized int numBssidSeen(String BSSID) {
 		String countQuery = "SELECT  COUNT(*) FROM " + AttackEntry.TABLE_NAME + " WHERE "
 				+ AttackEntry.TABLE_NAME + "." + AttackEntry.COLUMN_NAME_BSSID + " = " + "'" + BSSID + "'";
 		SQLiteDatabase db = this.getReadableDatabase();
@@ -301,7 +301,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
 	 * 
 	 * @return String[] of all recorded BSSIDs.
 	 */
-	public String[] getAllBSSIDS() {
+	public synchronized String[] getAllBSSIDS() {
 		String selectQuery = "SELECT  * FROM " + NetworkEntry.TABLE_NAME;
 		SQLiteDatabase db = this.getReadableDatabase();
 		Cursor cursor = db.rawQuery(selectQuery, null);
@@ -324,7 +324,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
 	 * 
 	 * @return The number of different attacks in the database.
 	 */
-	public int getAttackCount() {
+	public synchronized int getAttackCount() {
 		SQLiteDatabase db = this.getReadableDatabase();
 		String countQuery = "SELECT  * FROM " + AttackEntry.TABLE_NAME + 
 				           " WHERE " + AttackEntry.COLUMN_NAME_PROTOCOL + " <> ?";		
@@ -344,7 +344,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
 	 * @param bssid  The BSSID of the access point. 
 	 * @return The number of different attacks in the database since the given attack_id.
 	 */
-	public int getAttackCount(int attack_id, String bssid) {
+	public synchronized int getAttackCount(int attack_id, String bssid) {
 		SQLiteDatabase db = this.getReadableDatabase();
 		String countQuery = "SELECT * FROM " + AttackEntry.TABLE_NAME + 
 				           " WHERE "+ AttackEntry.COLUMN_NAME_PROTOCOL + " <> ? " +
@@ -371,7 +371,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
 	 *            Protocol}
 	 * @return The number of different attacks in the database.
 	 */
-	public int getAttackPerProtocolCount(String protocol) {
+	public synchronized int getAttackPerProtocolCount(String protocol) {
 		SQLiteDatabase db = this.getReadableDatabase();
 		String countQuery = "SELECT * FROM " + AttackEntry.TABLE_NAME + 
 		                   " WHERE "+ AttackEntry.COLUMN_NAME_PROTOCOL + " = ? ";	
@@ -395,7 +395,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
 	 * @param attack_id  The attack id to match the query against.
 	 * @return The number of different attacks in the database since the given attack_id.
 	 */
-	public int getAttackPerProtocolCount(String protocol, int attack_id) {
+	public synchronized int getAttackPerProtocolCount(String protocol, int attack_id) {
 		SQLiteDatabase db = this.getReadableDatabase();
 		String countQuery = "SELECT * FROM " + AttackEntry.TABLE_NAME + 
                 		   " WHERE "+ AttackEntry.COLUMN_NAME_PROTOCOL + " = ? " +
@@ -420,7 +420,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
 	 * @param bssid The BSSID of the access point. 
 	 * @return The number of different attacks in the database since the given attack_id.
 	 */
-	public int getAttackPerProtocolCount(String protocol, int attack_id, String bssid) {
+	public synchronized int getAttackPerProtocolCount(String protocol, int attack_id, String bssid) {
 		SQLiteDatabase db = this.getReadableDatabase();
 		String countQuery = "SELECT * FROM " + AttackEntry.TABLE_NAME + 
      		   			   " WHERE "+ AttackEntry.COLUMN_NAME_PROTOCOL + " = ? " +
@@ -440,7 +440,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
 	 * 
 	 * @return The number of portscans stored in the database.
 	 */
-	public int getPortscanCount() {
+	public synchronized int getPortscanCount() {
 		return getAttackPerProtocolCount("PORTSCAN");
 	}	
 	
@@ -449,7 +449,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
 	 * @param attack_id  The attack id to match the query against.
 	 * @return The number of portscans stored in the database since the given attack_id.
 	 */
-	public int getPortscanCount(int attack_id) {
+	public synchronized int getPortscanCount(int attack_id) {
 		return getAttackPerProtocolCount("PORTSCAN", attack_id);
 	}	
 	
@@ -459,7 +459,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
 	 * @param bssid The BSSID of the access point. 
 	 * @return The number of portscans stored in the database since the given attack_id.
 	 */
-	public int getPortscanCount(int attack_id, String bssid) {
+	public synchronized int getPortscanCount(int attack_id, String bssid) {
 		return getAttackPerProtocolCount("PORTSCAN", attack_id, bssid);
 	}	
 
@@ -469,7 +469,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
 	 * 
 	 * @return The number of {@link Record Records} in the database.
 	 */
-	public int getRecordCount() {
+	public synchronized int getRecordCount() {
 		String countQuery = "SELECT  * FROM " + PacketEntry.TABLE_NAME;
 		SQLiteDatabase db = this.getReadableDatabase();
 		Cursor cursor = db.rawQuery(countQuery, null);
@@ -511,7 +511,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
 	 * 
 	 * @return A ArrayList with a {@link AttackRecord} for each attack id in the Database.
 	 */
-	public ArrayList<AttackRecord> getRecordOfEachAttack() {
+	public synchronized ArrayList<AttackRecord> getRecordOfEachAttack() {
 		ArrayList<AttackRecord> recordList = new ArrayList<AttackRecord>();
 		String selectQuery = "SELECT  * FROM " + AttackEntry.TABLE_NAME;
 		SQLiteDatabase db = this.getReadableDatabase();
@@ -540,7 +540,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
 	 * @return A ArrayList with one {@link AttackRecord} for each attack id
 	 *         higher than the given.
 	 */
-	public ArrayList<AttackRecord> getRecordOfEachAttack(long attack_id) {
+	public synchronized ArrayList<AttackRecord> getRecordOfEachAttack(long attack_id) {
 		ArrayList<AttackRecord> recordList = new ArrayList<AttackRecord>();
 		String selectQuery = "SELECT  * FROM " + AttackEntry.TABLE_NAME + " WHERE " + AttackEntry.COLUMN_NAME_ATTACK_ID + " > " + attack_id;
 		SQLiteDatabase db = this.getReadableDatabase();
@@ -566,7 +566,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
 	 * 
 	 * @return The highest attack id stored in the database.
 	 */
-	public long getHighestAttackId() {
+	public synchronized long getHighestAttackId() {
 		String selectQuery = "SELECT MAX(" + AttackEntry.COLUMN_NAME_ATTACK_ID + ") FROM " + AttackEntry.TABLE_NAME;
 		SQLiteDatabase db = this.getReadableDatabase();
 		Cursor cursor = db.rawQuery(selectQuery, null);
@@ -587,7 +587,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
 	 * 
 	 * @return The smallest attack id stored in the database.
 	 */
-	public long getSmallestAttackId() {
+	public synchronized long getSmallestAttackId() {
 		String selectQuery = "SELECT MIN(" + AttackEntry.COLUMN_NAME_ATTACK_ID + ") FROM " + AttackEntry.TABLE_NAME;
 		SQLiteDatabase db = this.getReadableDatabase();
 		Cursor cursor = db.rawQuery(selectQuery, null);
@@ -611,7 +611,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
 	 * @return A String of the last SSID or null if the BSSID is not in the
 	 *         database.
 	 */
-	public String getSSID(String bssid) {
+	public synchronized String getSSID(String bssid) {
 		String selectQuery = "SELECT " + NetworkEntry.COLUMN_NAME_SSID + " FROM " + NetworkEntry.TABLE_NAME + " WHERE " + NetworkEntry.COLUMN_NAME_BSSID
 				+ " = " + "'" + bssid + "'";
 		SQLiteDatabase db = this.getReadableDatabase();
@@ -625,7 +625,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
 		return ssid;
 	}
 	
-	public ArrayList<NetworkRecord> getNetworkInformation() {
+	public synchronized ArrayList<NetworkRecord> getNetworkInformation() {
 		String selectQuery = "SELECT  * FROM " + NetworkEntry.TABLE_NAME;
 		SQLiteDatabase db = this.getReadableDatabase();
 		Cursor cursor = db.rawQuery(selectQuery, null);
@@ -693,7 +693,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
 	 * Returns a HashMap of all devices that were previously synchronized with.
 	 * @return HashMap containing device id's and the last synchronization timestamp.
 	 */
-	public HashMap<String, Long> getSyncDevices(){
+	public synchronized HashMap<String, Long> getSyncDevices(){
 		SQLiteDatabase db = this.getReadableDatabase();
 		HashMap<String, Long> devices = new HashMap<String, Long>();
 		
@@ -714,7 +714,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
 	 * Returns a ArrayList containing all information stored in the SyncInfo table.
 	 * @return ArrayList<SyncInfo>
 	 */
-	public ArrayList<SyncInfoRecord> getSyncInfo(){
+	public synchronized ArrayList<SyncInfoRecord> getSyncInfo(){
 		SQLiteDatabase db = this.getReadableDatabase();
 		ArrayList<SyncInfoRecord> syncInfo = new ArrayList<SyncInfoRecord>();
 		
@@ -737,13 +737,13 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
 	}	
 	
 	
-	public void updateSyncInfo(ArrayList<SyncInfoRecord> syncInfo){
+	public synchronized void updateSyncInfo(ArrayList<SyncInfoRecord> syncInfo){
 		for(SyncInfoRecord info : syncInfo){
 			updateSyncInfo(info);
 		}
 	}
 	
-	public void updateSyncInfo(SyncInfoRecord syncInfo){
+	public synchronized void updateSyncInfo(SyncInfoRecord syncInfo){
 		SQLiteDatabase db = this.getReadableDatabase();
 		ContentValues syncValues = new ContentValues();
 		syncValues.put(SyncInfoEntry.COLUMN_NAME_BSSID, syncInfo.getBSSID());
@@ -782,7 +782,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
 	 * @param bssid
 	 *            The BSSID to match against.
 	 */
-	public void deleteByBSSID(String bssid) {
+	public synchronized void deleteByBSSID(String bssid) {
 		SQLiteDatabase db = this.getReadableDatabase();
 		db.delete(NetworkEntry.TABLE_NAME, NetworkEntry.COLUMN_NAME_BSSID + " = ?", new String[] { bssid });
 		db.delete(AttackEntry.TABLE_NAME, AttackEntry.COLUMN_NAME_BSSID + " = ?", new String[] { bssid });
@@ -796,7 +796,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
 	 * @param date
 	 *            A Date represented in milliseconds.
 	 */
-	public void deleteByDate(long date) {
+	public synchronized void deleteByDate(long date) {
 		SQLiteDatabase db = this.getReadableDatabase();
 		String deleteQuery = "DELETE  FROM " + PacketEntry.TABLE_NAME + " WHERE " + PacketEntry.COLUMN_NAME_PACKET_TIMESTAMP + " < " + date;
 		db.execSQL(deleteQuery);
@@ -809,7 +809,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
 	 * @param attackID
 	 *            The Attack ID to match against.
 	 */
-	public void deleteByAttackID(long attackID) {
+	public synchronized void deleteByAttackID(long attackID) {
 		SQLiteDatabase db = this.getReadableDatabase();
 		db.delete(AttackEntry.TABLE_NAME, AttackEntry.COLUMN_NAME_ATTACK_ID + " = ?", new String[] { String.valueOf(attackID) });
 		db.delete(PacketEntry.TABLE_NAME, PacketEntry.COLUMN_NAME_ATTACK_ID + " = ?", new String[] { String.valueOf(attackID) });
@@ -823,7 +823,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
 	 * @param cursor
 	 * @return Returns the created {@link Record} .
 	 */
-	private MessageRecord createMessageRecord(Cursor cursor) {
+	private synchronized MessageRecord createMessageRecord(Cursor cursor) {
 		MessageRecord record = new MessageRecord();
 		record.setId(Integer.parseInt(cursor.getString(0)));
 		record.setAttack_id(cursor.getLong(1));
@@ -841,7 +841,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
 	 * @param cursor
 	 * @return Returns the created {@link Record} .
 	 */
-	private AttackRecord createAttackRecord(Cursor cursor) {
+	private synchronized AttackRecord createAttackRecord(Cursor cursor) {
 		AttackRecord record = new AttackRecord();
 		record.setAttack_id(cursor.getLong(0));
 		record.setProtocol(cursor.getString(1));
@@ -862,7 +862,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
 	 * @param cursor
 	 * @return Returns the created {@link Record} .
 	 */
-	private Record createRecord(Cursor cursor) {
+	private synchronized Record createRecord(Cursor cursor) {
 		Record record = new Record();
 		record.setId(Integer.parseInt(cursor.getString(0)));
 		record.setAttack_id(cursor.getLong(1));
@@ -895,7 +895,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
 	 * @return A ArrayList with all received {@link Record Records} for the
 	 *         LogFilter.
 	 */
-	public ArrayList<Record> getRecordsForFilter(LogFilter filter) {
+	public synchronized ArrayList<Record> getRecordsForFilter(LogFilter filter) {
 		ArrayList<Record> recordList = new ArrayList<Record>();
 		String selectQuery = "SELECT  * FROM " + PacketEntry.TABLE_NAME + " NATURAL JOIN " + AttackEntry.TABLE_NAME + " JOIN " + NetworkEntry.TABLE_NAME + " USING " + "(" + NetworkEntry.COLUMN_NAME_BSSID
 				+ ")";
@@ -954,7 +954,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
 	 * 
 	 * @return A arraylist with all {@link Record Records}s for an attack id.
 	 */
-	public ArrayList<Record> getConversationForAttackID(long attack_id) {
+	public synchronized ArrayList<Record> getConversationForAttackID(long attack_id) {
 		ArrayList<Record> recordList = new ArrayList<Record>();
 		String selectQuery = "SELECT  * FROM " + PacketEntry.TABLE_NAME + " NATURAL JOIN " + AttackEntry.TABLE_NAME + " JOIN " + NetworkEntry.TABLE_NAME + " USING " + "(" + NetworkEntry.COLUMN_NAME_BSSID
 				+ ")" + " WHERE " + PacketEntry.TABLE_NAME + "." + PacketEntry.COLUMN_NAME_ATTACK_ID + " = " + attack_id;
@@ -981,7 +981,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
 	 *            The attack id of the {@link Record};
 	 * @return The {@link Record}.
 	 */
-	public Record getRecordOfAttackId(long attack_id) {
+	public synchronized Record getRecordOfAttackId(long attack_id) {
 		String selectQuery = "SELECT  * FROM " + PacketEntry.TABLE_NAME + " NATURAL JOIN " + AttackEntry.TABLE_NAME + " JOIN " + NetworkEntry.TABLE_NAME + " USING " + "(" + NetworkEntry.COLUMN_NAME_BSSID
 				+ ")" + " WHERE " + PacketEntry.TABLE_NAME + "." + PacketEntry.COLUMN_NAME_ATTACK_ID + " = " + attack_id + " GROUP BY " + PacketEntry.TABLE_NAME + "." + PacketEntry.COLUMN_NAME_ID;
 		SQLiteDatabase db = this.getReadableDatabase();
@@ -1005,7 +1005,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
 	 *            The ID of the {@link Record};
 	 * @return The {@link Record}.
 	 */
-	public Record getRecord(int id) {
+	public synchronized Record getRecord(int id) {
 		String selectQuery = "SELECT  * FROM " + PacketEntry.TABLE_NAME + " NATURAL JOIN " + AttackEntry.TABLE_NAME + " JOIN " + NetworkEntry.TABLE_NAME + " USING " + "(" + PacketEntry.COLUMN_NAME_ATTACK_ID
 				+ ")" + " WHERE " + PacketEntry.TABLE_NAME + "." + PacketEntry.COLUMN_NAME_ID + " = " + id;
 		SQLiteDatabase db = this.getReadableDatabase();
@@ -1027,7 +1027,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
 	 * 
 	 * @return A ArrayList of all the {@link Record Records} in the Database.
 	 */
-	public ArrayList<Record> getAllRecords() {
+	public synchronized ArrayList<Record> getAllRecords() {
 		ArrayList<Record> recordList = new ArrayList<Record>();
 		// Select All Query
 		String selectQuery = "SELECT  * FROM " + PacketEntry.TABLE_NAME + " NATURAL JOIN " + AttackEntry.TABLE_NAME + " JOIN " + NetworkEntry.TABLE_NAME + " USING " + "(" + NetworkEntry.COLUMN_NAME_BSSID
@@ -1057,7 +1057,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
 	 * 
 	 * @return A ArrayList with received Records.
 	 */
-	public ArrayList<String> getUniqueBSSIDRecords() {
+	public synchronized ArrayList<String> getUniqueBSSIDRecords() {
 		return this.getUniqueDataEntryForKeyType(NetworkEntry.COLUMN_NAME_BSSID, NetworkEntry.TABLE_NAME);
 	}
 
@@ -1066,19 +1066,19 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
 	 * 
 	 * @return A ArrayList with received Records.
 	 */
-	public ArrayList<String> getUniqueESSIDRecords() {
+	public synchronized ArrayList<String> getUniqueESSIDRecords() {
 		return this.getUniqueDataEntryForKeyType(NetworkEntry.COLUMN_NAME_SSID, NetworkEntry.TABLE_NAME);
 	}
 
-	public ArrayList<String> getUniqueESSIDRecordsForProtocol(String protocol) {
+	public synchronized ArrayList<String> getUniqueESSIDRecordsForProtocol(String protocol) {
 		return this.getUniqueIDForProtocol(NetworkEntry.COLUMN_NAME_SSID, protocol);
 	}
 
-	public ArrayList<String> getUniqueBSSIDRecordsForProtocol(String protocol) {
+	public synchronized ArrayList<String> getUniqueBSSIDRecordsForProtocol(String protocol) {
 		return this.getUniqueIDForProtocol(NetworkEntry.COLUMN_NAME_BSSID, protocol);
 	}
 
-	private ArrayList<String> getUniqueIDForProtocol(String id, String protocol) {
+	private synchronized ArrayList<String> getUniqueIDForProtocol(String id, String protocol) {
 		ArrayList<String> recordList = new ArrayList<String>();
 		String selectQuery = "SELECT DISTINCT " + id + " FROM " + AttackEntry.TABLE_NAME + " JOIN " + NetworkEntry.TABLE_NAME + " USING " + "(" + NetworkEntry.COLUMN_NAME_BSSID + ") " + " WHERE "
 				+ AttackEntry.TABLE_NAME + "." + AttackEntry.COLUMN_NAME_PROTOCOL + " = " + "'" + protocol + "'" + " ORDER BY " + id; // " NATURAL JOIN "
@@ -1118,7 +1118,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
 	 * 
 	 * @return A ArrayList with received Records.
 	 */
-	public ArrayList<String> getUniqueDataEntryForKeyType(String keyType, String table) {
+	public synchronized ArrayList<String> getUniqueDataEntryForKeyType(String keyType, String table) {
 		ArrayList<String> recordList = new ArrayList<String>();
 		// String selectQuery = "SELECT  * FROM " + TABLE_RECORDS +
 		// " NATURAL JOIN " + TABLE_ATTACK_INFO + " NATURAL JOIN " +
@@ -1163,7 +1163,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
 	 * 
 	 * @return list of profiles
 	 */
-	public List<Profile> getAllProfiles() {
+	public synchronized List<Profile> getAllProfiles() {
 		List<Profile> profiles = new LinkedList<Profile>();
 
 		// Select All Query
@@ -1201,7 +1201,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
 	 * 
 	 * @return
 	 */
-	public long persistProfile(Profile profile) {
+	public synchronized long persistProfile(Profile profile) {
 		SQLiteDatabase db = this.getReadableDatabase();
 
 		ContentValues values = new ContentValues();
@@ -1228,7 +1228,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
 	 * KEY_PROFILE_ICON_ID + " INTEGER," + KEY_PROFILE_EDITABLE + " INTEGER," +
 	 * KEY_PROFILE_ACTIVE + " INTEGER" + ")";
 	 */
-	public Profile getProfile(int id) {
+	public synchronized Profile getProfile(int id) {
 		String selectQuery = "SELECT  * FROM " + ProfileEntry.TABLE_NAME + " WHERE " + ProfileEntry.TABLE_NAME + "." + ProfileEntry.COLUMN_NAME_PROFILE_ID + " = " + id;
 		SQLiteDatabase db = this.getReadableDatabase();
 
@@ -1253,7 +1253,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
 	}
 	
 
-	public void deleteProfile(int id) {
+	public synchronized void deleteProfile(int id) {
 		SQLiteDatabase db = this.getReadableDatabase();
 
 		db.delete(ProfileEntry.TABLE_NAME, ProfileEntry.COLUMN_NAME_PROFILE_ID + "=?", new String[] { String.valueOf(id) });
@@ -1267,7 +1267,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
 	 * @return A ArrayList with all received {@link Record Records} for each
 	 *         attack id in the Database.
 	 */
-	public ArrayList<Record> getAllReceivedRecordsOfEachAttack() {
+	public synchronized ArrayList<Record> getAllReceivedRecordsOfEachAttack() {
 		ArrayList<Record> recordList = new ArrayList<Record>();
 		String selectQuery = "SELECT  * FROM " + PacketEntry.TABLE_NAME + " NATURAL JOIN " + AttackEntry.TABLE_NAME + " JOIN " + NetworkEntry.TABLE_NAME + " USING " + "(" + NetworkEntry.COLUMN_NAME_BSSID
 				+ ")" + " WHERE " + PacketEntry.COLUMN_NAME_TYPE + "='RECEIVE'" + " ORDER BY " + PacketEntry.TABLE_NAME + "." + PacketEntry.COLUMN_NAME_PACKET_TIMESTAMP;