package com.extendedsharedpreferencessample;

import android.content.Context;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;

import com.extendedsharedpreferences.ExtendedSharedPreferences;
import com.extendedsharedpreferences.converter.GsonConverter;


public class MainActivity extends ActionBarActivity {

    private static final String TAG = MainActivity.class.getName();

    private ExtendedSharedPreferences sharedPreferences;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        sharedPreferences = new ExtendedSharedPreferences.Builder(this)
                .setName("MyPrefs")
                .setMode(Context.MODE_PRIVATE)
                .setConverter(new GsonConverter())
                .build();

        ComplexObject actual = new ComplexObject().fillSelf();
        sharedPreferences.edit().putObject("test", ComplexObject.class, actual).commit();
        ComplexObject expected = sharedPreferences.getObject("test", ComplexObject.class, null);
        Log.d(TAG, "The result of comparison of 'actual' and 'expected' is " + actual.equals(expected));
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
}

@@ -354,16 +354,55 @@
 verter;%0A
+import com.google.common.base.Objects;%0A
 %0A%0Apublic
@@ -974,32 +974,71 @@
 ild();%0A%0A        
+// Create complex object%0A        final 
 ComplexObject ac
@@ -1088,32 +1088,107 @@
     
-sharedPreferences.edit()
+// Write it to SharedPreferences%0A        sharedPreferences%0A                .edit()%0A                
 .put
@@ -1230,16 +1230,33 @@
  actual)
+%0A                
 .commit(
@@ -1254,24 +1254,65 @@
  .commit();%0A
+        // Get it from SharedPreferences%0A
         Comp
@@ -1396,16 +1396,42 @@
  null);%0A
+        // Check equality%0A
         
@@ -1505,22 +1505,468 @@
 %22 + 
-actual.equals(
+Objects.equal(actual, expected));%0A        // Remove preference%0A        sharedPreferences%0A                .edit()%0A                .putObject(%22test%22, ComplexObject.class, null)%0A                .commit();%0A        // Try to get object from SharedPreferences%0A        expected = sharedPreferences.getObject(%22test%22, ComplexObject.class, null);%0A        // Check equality%0A        Log.d(TAG, %22The result of comparison of 'null' and 'expected' is %22 + Objects.equal(null, 
 expe

update sample