Alexander Brakowski пре 10 година
родитељ
комит
8edf0eb287
1 измењених фајлова са 15 додато и 14 уклоњено
  1. 15 14
      src/de/tudarmstadt/informatik/hostage/persistence/HostageDBOpenHelper.java

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

@@ -853,7 +853,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
 	 * @see  {@link HostageDBOpenHelper#updateNetworkInformation(NetworkRecord record)}
 	 */
 	public synchronized void updateNetworkInformation(ArrayList<NetworkRecord> networkInformation) {
-        SQLiteDatabase db = this.getReadableDatabase();
+        SQLiteDatabase db = this.getWritableDatabase();
 
         db.beginTransaction();
         try {
@@ -889,7 +889,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
 	 * @param record The new {@link NetworkRecord}.
 	 */
 	public synchronized void updateNetworkInformation(NetworkRecord record) {
-		SQLiteDatabase db = this.getReadableDatabase();
+		SQLiteDatabase db = this.getWritableDatabase();
 		String bssid = record.getBssid();
 		String bssidQuery = "SELECT  * FROM " +  NetworkEntry.TABLE_NAME + " WHERE " +  NetworkEntry.COLUMN_NAME_BSSID + " = ?";
 		Cursor cursor = db.rawQuery(bssidQuery, new String[] {bssid});
@@ -914,7 +914,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
 	 * @param timestamp The synchronization timestamp
 	 */
 	public synchronized void updateTimestampOfSyncDevice(String deviceID, long timestamp){
-		SQLiteDatabase db = this.getReadableDatabase();		
+		SQLiteDatabase db = this.getWritableDatabase();
 		ContentValues deviceValues = new ContentValues();
 		deviceValues.put(SyncDeviceEntry.COLUMN_NAME_DEVICE_ID, deviceID);
 		deviceValues.put(SyncDeviceEntry.COLUMN_NAME_DEVICE_TIMESTAMP, timestamp);
@@ -927,7 +927,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
 	 * @param devices HashMap of device ids and their synchronization timestamps.
 	 */
 	public synchronized void updateSyncDevices(HashMap<String, Long> devices){
-		SQLiteDatabase db = this.getReadableDatabase();
+		SQLiteDatabase db = this.getWritableDatabase();
         db.beginTransaction();
 
         try {
@@ -946,7 +946,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
 	}
 
     public synchronized void updateSyncDevices(ArrayList<SyncDevice> devices){
-        SQLiteDatabase db = this.getReadableDatabase();
+        SQLiteDatabase db = this.getWritableDatabase();
         this.updateSyncDevices(devices, db);
         db.close();
     }
@@ -1067,7 +1067,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
 	 * @see  {@link HostageDBOpenHelper#updateSyncInfo(SyncInfoRecord syncInfo)}
 	 */
 	public synchronized void updateSyncInfo(ArrayList<SyncInfoRecord> syncInfos){
-        SQLiteDatabase db = this.getReadableDatabase();
+        SQLiteDatabase db = this.getWritableDatabase();
         db.beginTransaction();
 
         try {
@@ -1094,7 +1094,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
 	 * @param syncInfo The new {@link NetworkRecord}.
 	 */
 	public synchronized void updateSyncInfo(SyncInfoRecord syncInfo){
-		SQLiteDatabase db = this.getReadableDatabase();
+		SQLiteDatabase db = this.getWritableDatabase();
 		ContentValues syncValues = new ContentValues();
 		syncValues.put(SyncInfoEntry.COLUMN_NAME_BSSID, syncInfo.getBSSID());
 		syncValues.put(SyncInfoEntry.COLUMN_NAME_DEVICE_ID, syncInfo.getDeviceID());
@@ -1108,7 +1108,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
 	 * Deletes a device with given id from the device {@link de.tudarmstadt.informatik.hostage.persistence.HostageDBContract.SyncDeviceEntry} and also all data captured by this device in  {@link SyncInfoEntry}
 	 */
 	public synchronized void clearSyncInfos(){
-		SQLiteDatabase db = this.getReadableDatabase();
+		SQLiteDatabase db = this.getWritableDatabase();
 		db.delete(SyncDeviceEntry.TABLE_NAME, null, null);
 		db.delete(SyncInfoEntry.TABLE_NAME, null, null);
 		db.close();
@@ -1119,7 +1119,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
 	 * Deletes all records from {@link PacketEntry}s and {@link de.tudarmstadt.informatik.hostage.logging.AttackRecord}.
 	 */
 	public synchronized void clearData() {
-		SQLiteDatabase db = this.getReadableDatabase();
+		SQLiteDatabase db = this.getWritableDatabase();
 		db.delete(PacketEntry.TABLE_NAME, null, null);
 		db.delete(AttackEntry.TABLE_NAME, null, null);
 		db.close();
@@ -1132,7 +1132,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
 	 *            The BSSID to match against.
 	 */
 	public synchronized void deleteByBSSID(String bssid) {
-		SQLiteDatabase db = this.getReadableDatabase();
+		SQLiteDatabase db = this.getWritableDatabase();
 		db.delete(NetworkEntry.TABLE_NAME, NetworkEntry.COLUMN_NAME_BSSID + " = ?", new String[] { bssid });
 		db.delete(AttackEntry.TABLE_NAME, AttackEntry.COLUMN_NAME_BSSID + " = ?", new String[] { bssid });
 		db.close();
@@ -1146,7 +1146,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
 	 *            A Date represented in milliseconds.
 	 */
 	public synchronized void deleteByDate(long date) {
-		SQLiteDatabase db = this.getReadableDatabase();
+		SQLiteDatabase db = this.getWritableDatabase();
 		String deleteQuery = "DELETE  FROM " + PacketEntry.TABLE_NAME + " WHERE " + PacketEntry.COLUMN_NAME_PACKET_TIMESTAMP + " < " + date;
 		db.execSQL(deleteQuery);
 		db.close();
@@ -1159,7 +1159,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
 	 *            The Attack ID to match against.
 	 */
 	public synchronized void deleteByAttackID(long attackID) {
-		SQLiteDatabase db = this.getReadableDatabase();
+		SQLiteDatabase db = this.getWritableDatabase();
 		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) });
 		db.close();
@@ -1608,7 +1608,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
 	 * @return
 	 */
 	public synchronized long persistProfile(Profile profile) {
-		SQLiteDatabase db = this.getReadableDatabase();
+		SQLiteDatabase db = this.getWritableDatabase();
 
 		ContentValues values = new ContentValues();
 
@@ -1660,9 +1660,10 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
 	
 
 	public synchronized void deleteProfile(int id) {
-		SQLiteDatabase db = this.getReadableDatabase();
+		SQLiteDatabase db = this.getWritableDatabase();
 
 		db.delete(ProfileEntry.TABLE_NAME, ProfileEntry.COLUMN_NAME_PROFILE_ID + "=?", new String[] { String.valueOf(id) });
+        db.close();
 	}