1. activity_main.xml   =>   tools:context=".MainActivity"  => MainActivity.java

…….I try first… is more better  then post.

=========
=========
===== suggestion newbie =====
https://github.com/couchbaselabs/CouchbaseLite-DevDay-StarterKit
https://github.com/couchbaselabs/GrocerySync-Android

https://github.com/couchbaselabs/ToDoLite-Android        (Hard Understand) SO see this first:

http://sueboy.blogspot.com/2015/06/couchbase-todolist-get-database-sync.html

=========

MainActivity.java

  BuildConfig – 來自 build.gradle ( Module.app ) 目錄app – build.gradle

  extends ActionBarActivity – http://blog.tonycube.com/2014/02/android-actionbarcompat-1.html

  Intent – http://www.imyukin.com/?p=183
         – http://kezeodsnx.pixnet.net/blog/post/27072894-android-----%E6%87%89%E7%94%A8%E7%A8%8B%E5%BC%8F%E8%87%AA%E6%88%91%E4%BB%8B%E7%B4%B9%E4%B9%8Bintent-resolution

  startService – http://blog.maxkit.com.tw/2014/01/android-serviceintentservice.html
               – http://blog.kenyang.net/2012/11/android-startservice-vs-bindservice.html
               – http://blog.csdn.net/biezhihua/article/details/44439897
    context.bindService() <==> context.startService()
    context.startService() ==> Service <==> IntentService

  AsyncTask – http://a-can.logdown.com/blog/201623/android-asynctask-asynchronous-functions-are-carefully

  Observer – http://www.apkbus.com/android-112815-1-1.html

  runOnUiThread – http://lak4cyut.blogspot.com/2011/03/android-tip-activityrunonuithread.html
                – http://blog.csdn.net/zhang_yanye/article/details/40794629

  getApplication Application.java – http://www.cnblogs.com/duanxz/p/4379800.html

  Replication 同步local到remote – http://developer.couchbase.com/mobile/develop/references/couchbase-lite/couchbase-lite/replication/index.html

  application.getOnSyncProgressChangeObservable() –
    onSyncProgressChangeObservable –
      addObserver – http://www.apkbus.com/android-112815-1-1.html

  application.getOnSyncUnauthorizedObservable().addObserver(new Observer()

  application.startReplicationSyncWithCustomCookie 開始同步到remote

  DrawerLayout – http://ikevin.tw/?p=277

===== command see database =====
http://xxxx.xxxx.com:4985/_admin
http://xxxx.xxxx.com:4985/groupaccountingbooks/_session
http://xxxx.xxxx.com:4985/groupaccountingbooks/_user/
http://xxxx.xxxx.com:4985/groupaccountingbooks/_persona
http://xxxx.xxxx.com:4985/groupaccountingbooks/_changes
http://xxxx.xxxx.com:4985/groupaccountingbooks/_all_docs

open Sync Gateway GUEST account
http://xxxx.xxxx.com:4985/default/_user/GUEST –data  ‘{“disabled”:false, “admin_channels”:[“public”]}

add sync_gateway user (basic auth : user must exist on Sync Gateway.)
https://forums.couchbase.com/t/couchbase-lite-and-couchbase-sync-gate-way-authentication-failed/3993
https://forums.couchbase.com/t/user-authentication-document-best-practices/3086
http://sueboy.blogspot.com/2015/06/couchbase-basic-auth-basicauth.html
==========

===== couchbase todolist =====

getDeviceToken  ==> AsyncTask ==> doInBackground ==> GoogleCloudMessaging gcm

Synchronize.java <== Application.java <== Many use

===== android adapter view listen best way =====
http://androidadapternotifiydatasetchanged.blogspot.com/2013/02/android-notifydatasetchanged.html
http://stackoverflow.com/questions/4198425/updating-the-list-view-when-the-adapter-data-changes
https://developer.android.com/training/material/lists-cards.html

===== RecyclerView  =====
http://blog.csdn.net/guxiao1201/article/details/40423361
http://hmkcode.com/android-simple-recyclerview-widget-example/
http://blog.csdn.net/li396858359/article/details/40270921
http://www.eoeandroid.com/thread-535701-1-1.html
https://blog.nraboy.com/2015/04/create-a-couchbase-lite-todo-list-with-native-android/

===== RecyclerView onClick =====
http://stackoverflow.com/questions/24885223/why-doesnt-recyclerview-have-onitemclicklistener-and-how-recyclerview-is-dif
http://sueboy.blogspot.com/2015/06/recyclerview-onclick.html

===== Write your own Android Sync Adapter =====
http://blog.udinic.com/2013/07/24/write-your-own-android-sync-adapter/

==== Easy start new activity on button click =====
http://stackoverflow.com/questions/4186021/how-to-start-new-activity-on-button-click

===== How to add Secure Sync to your mobile apps =====
https://github.com/couchbaselabs/sg-live-demo

=====  save document =====
Map<String, Object> properties = new HashMap<String, Object>();
properties.put[“type”, “List”];
properties.put[“title”, title];
properties.put[“created_at”, currentTimeString];
properties.put[“owner”, “profile:"+ userId];
properties.put[“members”,, new ArrayList()];

//save to database
Document document = database.cretaeDocument();
document.putProperties(properties);

===== read document =====
Document document = database.getDocumnet(mDocId);
String title = document.getProperty(“title”);

Map<String, Objectt> properties = doc.getProperties();
String owner = (String) properties.get(“owner”);

===== Push Pull =====
Push => Server or couchbase SyncGateway
Pull <= Server or couchbase SyncGateway

===== cookie auth =====
app calls my server which POST to SyncGateway’s _session
https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!msg/mobile-couchbase/83srQTNmXj0/sPOW61ZWNtkJ