|
@@ -1,262 +1,262 @@
|
|
|
-package de.tudarmstadt.informatik.hostage.ui;
|
|
|
-
|
|
|
-import java.net.InetAddress;
|
|
|
-import java.net.UnknownHostException;
|
|
|
-import java.text.DateFormat;
|
|
|
-import java.text.SimpleDateFormat;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Calendar;
|
|
|
-import java.util.Collections;
|
|
|
-import java.util.Comparator;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.HashMap;
|
|
|
-
|
|
|
-import android.annotation.SuppressLint;
|
|
|
-import android.app.Activity;
|
|
|
-import android.content.Context;
|
|
|
-import android.content.Intent;
|
|
|
-import android.content.SharedPreferences;
|
|
|
-import android.os.Bundle;
|
|
|
-import android.view.Menu;
|
|
|
-import android.view.MenuItem;
|
|
|
-import android.view.View;
|
|
|
-import android.widget.AdapterView;
|
|
|
-import android.widget.ListAdapter;
|
|
|
-import android.widget.ListView;
|
|
|
-import android.widget.SimpleAdapter;
|
|
|
-import android.widget.Toast;
|
|
|
-import de.tudarmstadt.informatik.hostage.R;
|
|
|
-import de.tudarmstadt.informatik.hostage.logging.DatabaseHandler;
|
|
|
-import de.tudarmstadt.informatik.hostage.logging.Record;
|
|
|
-import de.tudarmstadt.informatik.hostage.logging.Record.TYPE;
|
|
|
-
|
|
|
-/**
|
|
|
- * Creates a simple log view. Shows the Information for every attack. The format
|
|
|
- * ist defined in {@link Record#toString(int)}.
|
|
|
- *
|
|
|
- * @author Lars Pandikow
|
|
|
- *
|
|
|
- */
|
|
|
-@SuppressLint("NewApi")
|
|
|
-public class ViewLogTable extends Activity{
|
|
|
- DatabaseHandler dbh;
|
|
|
-
|
|
|
- private ArrayList<String> selectedProtocols;
|
|
|
-
|
|
|
- private LogFilter filter;
|
|
|
- private boolean showFilterButton;
|
|
|
-
|
|
|
- @Override
|
|
|
- protected void onCreate(Bundle savedInstanceState) {
|
|
|
- super.onCreate(savedInstanceState);
|
|
|
-
|
|
|
- // Get the message from the intent
|
|
|
- Intent intent = getIntent();
|
|
|
- LogFilter filter = intent.getParcelableExtra(LogFilter.LOG_FILTER_INTENT_KEY);
|
|
|
-
|
|
|
- if(filter == null){
|
|
|
- this.filter = new LogFilter();
|
|
|
- } else {
|
|
|
- this.filter = filter;
|
|
|
- }
|
|
|
-
|
|
|
- this.showFilterButton = !filter.isNotEditable();
|
|
|
-
|
|
|
-
|
|
|
- this.selectedProtocols = new ArrayList<String>();
|
|
|
-
|
|
|
-// for (String protocol : this.getResources().getStringArray(
|
|
|
-// R.array.protocols)) {
|
|
|
-// this.selectedProtocols.add(protocol);
|
|
|
-// }
|
|
|
-
|
|
|
- dbh = new DatabaseHandler(getBaseContext());
|
|
|
- setContentView(R.layout.activity_loglist);
|
|
|
-
|
|
|
- this.addRecordToDB();
|
|
|
-
|
|
|
- populateListViewFromDB();
|
|
|
- registerListClickCallback();
|
|
|
- }
|
|
|
-
|
|
|
- public class RecordComparator implements Comparator<Record> {
|
|
|
- public int compare(Record o1, Record o2) {
|
|
|
- long time1 = o1.getTimestamp();
|
|
|
- long time2 = o2.getTimestamp();
|
|
|
- if (time1 < time2)
|
|
|
- return -1;
|
|
|
- if (time1 > time2)
|
|
|
- return 1;
|
|
|
- return 0;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void addRecordToDB() {
|
|
|
- Calendar cal = Calendar.getInstance();
|
|
|
-
|
|
|
- int maxProtocolsIndex = this.getResources().getStringArray(
|
|
|
- R.array.protocols).length;
|
|
|
-
|
|
|
- int numberofRecords = (int) (Math.random() * (50 - 10));
|
|
|
- for (int i = 0; i < numberofRecords; i++) {
|
|
|
- Record record = new Record();
|
|
|
- record.setBSSID("BSSID: " + i);
|
|
|
- record.setSSID("SSID: w" + i);
|
|
|
- record.setTimestamp(cal.getTimeInMillis()
|
|
|
- + ((i * 60 * 60 * 60 * 24) * 1000));
|
|
|
-
|
|
|
- int index = i % maxProtocolsIndex;
|
|
|
- String protocolName = this.getResources().getStringArray(
|
|
|
- R.array.protocols)[index];
|
|
|
-
|
|
|
- record.setProtocol(protocolName);
|
|
|
- record.setId(i);
|
|
|
- record.setAttack_id(i);
|
|
|
- try {
|
|
|
- InetAddress localIP = InetAddress.getByAddress("Digga",
|
|
|
- new byte[] { 127, 0, 0, 1 }); // .getByName("192.168.2.1");
|
|
|
- record.setLocalIP(localIP);
|
|
|
- record.setRemoteIP(InetAddress.getByAddress("Digga",
|
|
|
- new byte[] { 127, 1, 1, 1 }));
|
|
|
- record.setType(TYPE.SEND);
|
|
|
- } catch (UnknownHostException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
-
|
|
|
- dbh.addRecord(record);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void populateListViewFromDB() {
|
|
|
-
|
|
|
- ListView mylist = (ListView) findViewById(R.id.loglistview);
|
|
|
-
|
|
|
- ArrayList<HashMap<String, String>> Items = new ArrayList<HashMap<String, String>>();
|
|
|
-
|
|
|
- ArrayList<Record> data = dbh.getRecordsForFilter(this.filter);
|
|
|
- Collections.sort(data, new RecordComparator());
|
|
|
-
|
|
|
-
|
|
|
- for (Record val : data) {
|
|
|
- HashMap<String, String> map = new HashMap<String, String>();
|
|
|
- map.put(this.getString(R.string.RecordBSSID), val.getBSSID() );
|
|
|
- map.put(this.getString(R.string.RecordSSID), val.getSSID());
|
|
|
- map.put(this.getString(R.string.RecordProtocol), val.getProtocol());
|
|
|
- map.put(this.getString(R.string.RecordTimestamp), this.getDateAsString(val.getTimestamp()));
|
|
|
- Items.add(map);
|
|
|
- }
|
|
|
-
|
|
|
- // Adding Items to ListView
|
|
|
- String keys[] = new String[] { this.getString(R.string.RecordBSSID), this.getString(R.string.RecordSSID), this.getString(R.string.RecordProtocol), this.getString(R.string.RecordTimestamp)};
|
|
|
- int ids[] = new int[] {R.id.RecordTextFieldBSSID, R.id.RecordTextFieldSSID, R.id.RecordTextFieldProtocol, R.id.RecordTextFieldTimestamp };
|
|
|
-
|
|
|
- ListAdapter adapter = new SimpleAdapter(this, Items, R.layout.loglist_row, keys, ids);
|
|
|
-
|
|
|
- mylist.setAdapter(adapter);
|
|
|
- }
|
|
|
-
|
|
|
- @SuppressLint("SimpleDateFormat")
|
|
|
- private String getDateAsString(long timeStamp) {
|
|
|
-
|
|
|
- try {
|
|
|
- DateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
|
|
|
- Date netDate = (new Date(timeStamp));
|
|
|
- return sdf.format(netDate);
|
|
|
- } catch (Exception ex) {
|
|
|
- return "xx";
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void registerListClickCallback() {
|
|
|
- ListView mylist = (ListView) findViewById(R.id.loglistview);
|
|
|
-
|
|
|
- mylist.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
|
- public void onItemClick(AdapterView<?> parent, View viewClicked,
|
|
|
- int position, long idInDB) {
|
|
|
- DatabaseHandler dbh = new DatabaseHandler(getBaseContext());
|
|
|
- Record rec = dbh.getRecord((int) idInDB);
|
|
|
- String message = createInformationStringFromRecord(rec);
|
|
|
- Toast.makeText(getApplicationContext(), message,
|
|
|
- Toast.LENGTH_LONG).show();
|
|
|
- }
|
|
|
-
|
|
|
- private String createInformationStringFromRecord(Record rec) {
|
|
|
- String message = "id: " + rec.getId() + "\n" + "attack_id: "
|
|
|
- + rec.getAttack_id() + "\n" + "protocol: "
|
|
|
- + rec.getProtocol() + "\n" + "type: " + rec.getType()
|
|
|
- + "\n" + "externalIP: " + rec.getExternalIP() + "\n"
|
|
|
- + "localIP: " + rec.getLocalIP() + "\n"
|
|
|
- + "local port: " + rec.getLocalPort() + "\n"
|
|
|
- + "remoteIP: " + rec.getRemoteIP() + "\n" + "BSSID: "
|
|
|
- + rec.getBSSID() + "\n" + "SSID: " + rec.getSSID()
|
|
|
- + "\n" + "latitude: " + rec.getLatitude() + "\n"
|
|
|
- + "longitude: " + rec.getLongitude() + "\n"
|
|
|
- + "accuracy: " + rec.getAccuracy() + "\n" + "packet: "
|
|
|
- + rec.getPacket() + "\n"
|
|
|
- + getDateAsString(rec.getTimestamp()) + "";
|
|
|
- return message;
|
|
|
- }
|
|
|
-
|
|
|
- @SuppressLint("SimpleDateFormat")
|
|
|
- private String getDateAsString(long timeStamp) {
|
|
|
-
|
|
|
- try {
|
|
|
- DateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
|
|
|
- Date netDate = (new Date(timeStamp));
|
|
|
- return sdf.format(netDate);
|
|
|
- } catch (Exception ex) {
|
|
|
- return "xx";
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public boolean onCreateOptionsMenu(Menu menu) {
|
|
|
- super.onCreateOptionsMenu(menu);
|
|
|
- if(this.showFilterButton){
|
|
|
- MenuItem item = menu.add("Filter");
|
|
|
-
|
|
|
-
|
|
|
- // MenuInflater inflater = getMenuInflater();
|
|
|
- // inflater.inflate(R.menu.listview_detail_menu, menu);
|
|
|
- return true;
|
|
|
- } else {
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public boolean onOptionsItemSelected(MenuItem item) {
|
|
|
-
|
|
|
- this.openFilterMenu(item.getActionView());
|
|
|
-
|
|
|
- this.populateListViewFromDB();
|
|
|
- return super.onOptionsItemSelected(item);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- private void openFilterMenu(View anchorView){
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- private void saveInSharedPreferences(String key, boolean value) {
|
|
|
- // --SAVE Data
|
|
|
- SharedPreferences preferences = this.getSharedPreferences();
|
|
|
- SharedPreferences.Editor editor = preferences.edit();
|
|
|
- editor.putBoolean(key, value);
|
|
|
- editor.commit();
|
|
|
- }
|
|
|
-
|
|
|
- private boolean getBooleanInSharedPreferences(String key) {
|
|
|
- SharedPreferences preferences = this.getSharedPreferences();
|
|
|
- return preferences.getBoolean(key, true);
|
|
|
- }
|
|
|
-
|
|
|
- private SharedPreferences getSharedPreferences() {
|
|
|
- return this.getSharedPreferences("HostagePreferences",
|
|
|
- Context.MODE_PRIVATE);
|
|
|
- }
|
|
|
-
|
|
|
-}
|
|
|
+package de.tudarmstadt.informatik.hostage.ui;
|
|
|
+
|
|
|
+import java.net.InetAddress;
|
|
|
+import java.net.UnknownHostException;
|
|
|
+import java.text.DateFormat;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Calendar;
|
|
|
+import java.util.Collections;
|
|
|
+import java.util.Comparator;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+
|
|
|
+import android.annotation.SuppressLint;
|
|
|
+import android.app.Activity;
|
|
|
+import android.content.Context;
|
|
|
+import android.content.Intent;
|
|
|
+import android.content.SharedPreferences;
|
|
|
+import android.os.Bundle;
|
|
|
+import android.view.Menu;
|
|
|
+import android.view.MenuItem;
|
|
|
+import android.view.View;
|
|
|
+import android.widget.AdapterView;
|
|
|
+import android.widget.ListAdapter;
|
|
|
+import android.widget.ListView;
|
|
|
+import android.widget.SimpleAdapter;
|
|
|
+import android.widget.Toast;
|
|
|
+import de.tudarmstadt.informatik.hostage.R;
|
|
|
+import de.tudarmstadt.informatik.hostage.logging.DatabaseHandler;
|
|
|
+import de.tudarmstadt.informatik.hostage.logging.Record;
|
|
|
+import de.tudarmstadt.informatik.hostage.logging.Record.TYPE;
|
|
|
+
|
|
|
+/**
|
|
|
+ * Creates a simple log view. Shows the Information for every attack. The format
|
|
|
+ * ist defined in {@link Record#toString(int)}.
|
|
|
+ *
|
|
|
+ * @author Lars Pandikow
|
|
|
+ *
|
|
|
+ */
|
|
|
+@SuppressLint("NewApi")
|
|
|
+public class ViewLogTable extends Activity{
|
|
|
+ DatabaseHandler dbh;
|
|
|
+
|
|
|
+ private ArrayList<String> selectedProtocols;
|
|
|
+
|
|
|
+ private LogFilter filter;
|
|
|
+ private boolean showFilterButton;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void onCreate(Bundle savedInstanceState) {
|
|
|
+ super.onCreate(savedInstanceState);
|
|
|
+
|
|
|
+ // Get the message from the intent
|
|
|
+ Intent intent = getIntent();
|
|
|
+ LogFilter filter = intent.getParcelableExtra(LogFilter.LOG_FILTER_INTENT_KEY);
|
|
|
+
|
|
|
+ if(filter == null){
|
|
|
+ this.filter = new LogFilter();
|
|
|
+ } else {
|
|
|
+ this.filter = filter;
|
|
|
+ }
|
|
|
+
|
|
|
+ this.showFilterButton = !filter.isNotEditable();
|
|
|
+
|
|
|
+
|
|
|
+ this.selectedProtocols = new ArrayList<String>();
|
|
|
+
|
|
|
+// for (String protocol : this.getResources().getStringArray(
|
|
|
+// R.array.protocols)) {
|
|
|
+// this.selectedProtocols.add(protocol);
|
|
|
+// }
|
|
|
+
|
|
|
+ dbh = new DatabaseHandler(getBaseContext());
|
|
|
+ setContentView(R.layout.activity_loglist);
|
|
|
+
|
|
|
+ this.addRecordToDB();
|
|
|
+
|
|
|
+ populateListViewFromDB();
|
|
|
+ registerListClickCallback();
|
|
|
+ }
|
|
|
+
|
|
|
+ public class RecordComparator implements Comparator<Record> {
|
|
|
+ public int compare(Record o1, Record o2) {
|
|
|
+ long time1 = o1.getTimestamp();
|
|
|
+ long time2 = o2.getTimestamp();
|
|
|
+ if (time1 < time2)
|
|
|
+ return -1;
|
|
|
+ if (time1 > time2)
|
|
|
+ return 1;
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void addRecordToDB() {
|
|
|
+ Calendar cal = Calendar.getInstance();
|
|
|
+
|
|
|
+ int maxProtocolsIndex = this.getResources().getStringArray(
|
|
|
+ R.array.protocols).length;
|
|
|
+
|
|
|
+ int numberofRecords = (int) (Math.random() * (50 - 10));
|
|
|
+ for (int i = 0; i < numberofRecords; i++) {
|
|
|
+ Record record = new Record();
|
|
|
+ record.setBSSID("BSSID: " + i);
|
|
|
+ record.setSSID("SSID: w" + i);
|
|
|
+ record.setTimestamp(cal.getTimeInMillis()
|
|
|
+ + ((i * 60 * 60 * 60 * 24) * 1000));
|
|
|
+
|
|
|
+ int index = i % maxProtocolsIndex;
|
|
|
+ String protocolName = this.getResources().getStringArray(
|
|
|
+ R.array.protocols)[index];
|
|
|
+
|
|
|
+ record.setProtocol(protocolName);
|
|
|
+ record.setId(i);
|
|
|
+ record.setAttack_id(i);
|
|
|
+ try {
|
|
|
+ InetAddress localIP = InetAddress.getByAddress("Digga",
|
|
|
+ new byte[] { 127, 0, 0, 1 }); // .getByName("192.168.2.1");
|
|
|
+ record.setLocalIP(localIP);
|
|
|
+ record.setRemoteIP(InetAddress.getByAddress("Digga",
|
|
|
+ new byte[] { 127, 1, 1, 1 }));
|
|
|
+ record.setType(TYPE.SEND);
|
|
|
+ } catch (UnknownHostException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ dbh.addRecord(record);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void populateListViewFromDB() {
|
|
|
+
|
|
|
+ ListView mylist = (ListView) findViewById(R.id.loglistview);
|
|
|
+
|
|
|
+ ArrayList<HashMap<String, String>> Items = new ArrayList<HashMap<String, String>>();
|
|
|
+
|
|
|
+ ArrayList<Record> data = dbh.getRecordsForFilter(this.filter);
|
|
|
+ Collections.sort(data, new RecordComparator());
|
|
|
+
|
|
|
+
|
|
|
+ for (Record val : data) {
|
|
|
+ HashMap<String, String> map = new HashMap<String, String>();
|
|
|
+ map.put(this.getString(R.string.RecordBSSID), val.getBSSID() );
|
|
|
+ map.put(this.getString(R.string.RecordSSID), val.getSSID());
|
|
|
+ map.put(this.getString(R.string.RecordProtocol), val.getProtocol());
|
|
|
+ map.put(this.getString(R.string.RecordTimestamp), this.getDateAsString(val.getTimestamp()));
|
|
|
+ Items.add(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ // Adding Items to ListView
|
|
|
+ String keys[] = new String[] { this.getString(R.string.RecordBSSID), this.getString(R.string.RecordSSID), this.getString(R.string.RecordProtocol), this.getString(R.string.RecordTimestamp)};
|
|
|
+ int ids[] = new int[] {R.id.RecordTextFieldBSSID, R.id.RecordTextFieldSSID, R.id.RecordTextFieldProtocol, R.id.RecordTextFieldTimestamp };
|
|
|
+
|
|
|
+ ListAdapter adapter = new SimpleAdapter(this, Items, R.layout.loglist_row, keys, ids);
|
|
|
+
|
|
|
+ mylist.setAdapter(adapter);
|
|
|
+ }
|
|
|
+
|
|
|
+ @SuppressLint("SimpleDateFormat")
|
|
|
+ private String getDateAsString(long timeStamp) {
|
|
|
+
|
|
|
+ try {
|
|
|
+ DateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
|
|
|
+ Date netDate = (new Date(timeStamp));
|
|
|
+ return sdf.format(netDate);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ return "xx";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void registerListClickCallback() {
|
|
|
+ ListView mylist = (ListView) findViewById(R.id.loglistview);
|
|
|
+
|
|
|
+ mylist.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
|
+ public void onItemClick(AdapterView<?> parent, View viewClicked,
|
|
|
+ int position, long idInDB) {
|
|
|
+ DatabaseHandler dbh = new DatabaseHandler(getBaseContext());
|
|
|
+ Record rec = dbh.getRecord((int) idInDB);
|
|
|
+ String message = createInformationStringFromRecord(rec);
|
|
|
+ Toast.makeText(getApplicationContext(), message,
|
|
|
+ Toast.LENGTH_LONG).show();
|
|
|
+ }
|
|
|
+
|
|
|
+ private String createInformationStringFromRecord(Record rec) {
|
|
|
+ String message = "id: " + rec.getId() + "\n" + "attack_id: "
|
|
|
+ + rec.getAttack_id() + "\n" + "protocol: "
|
|
|
+ + rec.getProtocol() + "\n" + "type: " + rec.getType()
|
|
|
+ + "\n" + "externalIP: " + rec.getExternalIP() + "\n"
|
|
|
+ + "localIP: " + rec.getLocalIP() + "\n"
|
|
|
+ + "local port: " + rec.getLocalPort() + "\n"
|
|
|
+ + "remoteIP: " + rec.getRemoteIP() + "\n" + "BSSID: "
|
|
|
+ + rec.getBSSID() + "\n" + "SSID: " + rec.getSSID()
|
|
|
+ + "\n" + "latitude: " + rec.getLatitude() + "\n"
|
|
|
+ + "longitude: " + rec.getLongitude() + "\n"
|
|
|
+ + "accuracy: " + rec.getAccuracy() + "\n" + "packet: "
|
|
|
+ + rec.getPacket() + "\n"
|
|
|
+ + getDateAsString(rec.getTimestamp()) + "";
|
|
|
+ return message;
|
|
|
+ }
|
|
|
+
|
|
|
+ @SuppressLint("SimpleDateFormat")
|
|
|
+ private String getDateAsString(long timeStamp) {
|
|
|
+
|
|
|
+ try {
|
|
|
+ DateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
|
|
|
+ Date netDate = (new Date(timeStamp));
|
|
|
+ return sdf.format(netDate);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ return "xx";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean onCreateOptionsMenu(Menu menu) {
|
|
|
+ super.onCreateOptionsMenu(menu);
|
|
|
+ if(this.showFilterButton){
|
|
|
+ MenuItem item = menu.add("Filter");
|
|
|
+
|
|
|
+
|
|
|
+ // MenuInflater inflater = getMenuInflater();
|
|
|
+ // inflater.inflate(R.menu.listview_detail_menu, menu);
|
|
|
+ return true;
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean onOptionsItemSelected(MenuItem item) {
|
|
|
+
|
|
|
+ this.openFilterMenu(item.getActionView());
|
|
|
+
|
|
|
+ this.populateListViewFromDB();
|
|
|
+ return super.onOptionsItemSelected(item);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private void openFilterMenu(View anchorView){
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void saveInSharedPreferences(String key, boolean value) {
|
|
|
+ // --SAVE Data
|
|
|
+ SharedPreferences preferences = this.getSharedPreferences();
|
|
|
+ SharedPreferences.Editor editor = preferences.edit();
|
|
|
+ editor.putBoolean(key, value);
|
|
|
+ editor.commit();
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean getBooleanInSharedPreferences(String key) {
|
|
|
+ SharedPreferences preferences = this.getSharedPreferences();
|
|
|
+ return preferences.getBoolean(key, true);
|
|
|
+ }
|
|
|
+
|
|
|
+ private SharedPreferences getSharedPreferences() {
|
|
|
+ return this.getSharedPreferences("HostagePreferences",
|
|
|
+ Context.MODE_PRIVATE);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|