title: How to encrypt/decrypt in SQLCipher
body: <p>I am struggling with <strong>How to encrypt/decrypt DB with SQLCipher.</strong></p>
  
  <p>In my this code from where i should start. and how to start.</p>
  
  <p>Please Edit this code if possible.</p>
  
  <p>I followed this link but not getting how to do that. <a href="http://sqlcipher.net/sqlcipher-api/#key" rel="nofollow">http://sqlcipher.net/sqlcipher-api/#key</a></p>
  
  <p>My DB file:-</p>
  
  <pre><code>import net.sqlcipher.database.SQLiteDatabase;
  import net.sqlcipher.database.SQLiteOpenHelper;
  import android.content.Context;
  import android.util.Log;
  
  public class DatabaseClass extends SQLiteOpenHelper 
  {
      /**
       * Constants 
       */
      public final static String DATABASE_NAME ="mycipherdatabase.db";
      public final static String NAME ="name";
      public final static String ADDRESS ="address";
      public final static String CITY ="city";
  
      public static String pass = "1234";
      public DatabaseClass(Context context) {
          super(context, DATABASE_NAME, null, 1);
      }
  
      /**
       * called once
       */
      @Override
      public void onCreate(SQLiteDatabase db) {
          db.execSQL( "CREATE TABLE mylistdata(_id INTEGER PRIMARY KEY AUTOINCREMENT,name TEXT, address TEXT,city TEXT);");
  
          Log.v("inside", "oncreate");
      }
  
      /**
       * called when we upgrade(change)the version number of database
       * onCreate also called after changing the version
       */
      @Override
      public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
          db.execSQL("DROP Table mylistdata");
          onCreate(db);
      }
  }
  </code></pre>
  
  <p>OtherActivity Using this DB:-</p>
  
  <pre><code>/** Called when the activity is first created. */
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
  
          SQLiteDatabase.loadLibs(this);
          File file = getDatabasePath(DatabaseClass.DATABASE_NAME);
          file.mkdir();
          file.delete();
          sqldb = SQLiteDatabase.openOrCreateDatabase(file,key, null);
          db = new DatabaseClass(this);
  
          etname = (EditText)findViewById(R.id.name);
          etadd = (EditText)findViewById(R.id.add);
          etcity = (EditText)findViewById(R.id.city);
          result = (ListView)findViewById(R.id.mylist);
      }
  
      /**
       *insert data in to database 
       */
      public void saveData(View v) {
          ContentValues insertData = new ContentValues();
          insertData.put(DatabaseClass.NAME, etname.getText().toString());
          insertData.put(DatabaseClass.ADDRESS, etadd.getText().toString());
          insertData.put(DatabaseClass.CITY, etcity.getText().toString());
  
          db.getWritableDatabase(key).insert("mylistdata", DatabaseClass.NAME , insertData);
          db.close();
  
          resetEditText();
          Toast.makeText(this,"Data saved", Toast.LENGTH_SHORT).show();
      }
  </code></pre>