{"id":22413586,"url":"https://github.com/nextfaze/couchdbsyncer-android","last_synced_at":"2025-07-31T23:31:33.884Z","repository":{"id":138429722,"uuid":"1792946","full_name":"NextFaze/couchdbsyncer-android","owner":"NextFaze","description":"android library for synchronising a couchdb database to a local sqlite database","archived":false,"fork":false,"pushed_at":"2011-12-02T01:16:54.000Z","size":442,"stargazers_count":4,"open_issues_count":1,"forks_count":3,"subscribers_count":20,"default_branch":"master","last_synced_at":"2024-04-20T13:40:56.786Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://github.com/NextfazeSD/couchdbsyncer-android","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NextFaze.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-05-24T11:00:23.000Z","updated_at":"2016-04-04T20:35:54.000Z","dependencies_parsed_at":"2023-03-14T11:31:24.425Z","dependency_job_id":null,"html_url":"https://github.com/NextFaze/couchdbsyncer-android","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NextFaze%2Fcouchdbsyncer-android","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NextFaze%2Fcouchdbsyncer-android/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NextFaze%2Fcouchdbsyncer-android/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NextFaze%2Fcouchdbsyncer-android/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NextFaze","download_url":"https://codeload.github.com/NextFaze/couchdbsyncer-android/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228312126,"owners_count":17900219,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-05T14:13:33.434Z","updated_at":"2024-12-05T14:13:35.664Z","avatar_url":"https://github.com/NextFaze.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"couchdbsyncer-android\n=====================\n\nsyncs couchdb databases from the server, saving documents and attachments locally in an sqlite database.\n\nAdding to your project\n----------------------\n\nReference the couchdbsyncer-android project as a library (Properties -\u003e Android -\u003e Library -\u003e Add in eclipse) and reference libs/*.jar as external jars.\nAlternatively, create a jar from au.com.team2moro.couchdbsyncer (include au.com.team2moro.couchdbsyncer.data), and add to your Android project.\n\nYou must have the following line in your AndroidManifest.xml:\n\n    \u003cuses-permission android:name=\"android.permission.INTERNET\"\u003e\u003c/uses-permission\u003e\n    \nUsage\n-----\n\nDatabaseStore handles the storage of documents and attachments from one or more CouchDB databases.  Applications will typically create a single shared instance of DatabaseStore.\n\na Syncer object is used to download changes from a remote CouchDB database to the local sqlite database. The Syncer uses the bulk document fetch API (http://wiki.apache.org/couchdb/HTTP_Bulk_Document_API) to fetch all changed documents in a single HTTP request.\n\nSyncerService can be subclassed to provide a IntentService to run a syncer update. At minimum your subclass must provide an implementation for the abstract getDatabaseStore() method.\n\nSee also the au.com.team2moro.couchdbsyncerexample application for an example application.\n\nSynopsis\n--------\n\ncreate a DatabaseStore and a Database to sync to (this will probably happen in your Application class)\n\n    public static final String DB_NAME = \"my_database_name\";\n    public static final String SHIPPED_DB = \"my_db.sqlite\";   // in assets folder\n    public static final String DB_URL = \"http://example.com:5984/db_name\";\n\n    @Override\n    public void onCreate() {\n        super.onCreate();\n        \n        // create a new database store.\n        // if SHIPPED_DB is newer than the internal database or the\n        // internal database does not exist, SHIPPED_DB is installed\n        // as the current database.\n        dbstore = new DatabaseStore(this, SHIPPED_DB);\n\n        // get the database DB_NAME.  updates the database url to the given URL.\n        // creates a new local database record if it has not been created yet.\n        database = dbstore.getDatabase(DB_NAME, new URL(DB_URL));\n    }\n    public DatabaseStore getDatabaseStore() {\n        return dbstore;\n    }\n    public Database getDatabase() {\n        return database;\n    }\n \nSubclass SyncerService to create an IntentService that will run a sync operation.  Your subclass can provide HTTP credentials and a download policy if required.  Your implementation might look like:\n\n    public class MySyncerService extends SyncerService {\n        public DatabaseStore getDatabaseStore() {\n            return ((MyApplication)getApplication()).getDatabaseStore();\n        }\n    }\n\nThen sync the database like this:\n\n    intent = new Intent(this, MySyncerService.class);\n    intent.putExtra(\"database_name\", \"my_database_name\");\n    startService(intent);\n\nDownload policies\n-----------------\n\nThe DownloadPolicy interface allows control over which documents and attachments are downloaded to the local sqlite database from the server.  By default, all documents and attachments are downloaded except design documents.\nIt also allows control over download thread priority, which currently has no effect because the downloads all run in a single thread.\nTODO: implement multi-thread downloads.\n\nAccessing documents / attachments\n---------------------------------\n\nSee DatabaseStore getDocument() and getAttachment() methods.\nSome example code that fetches all documents of type 'Dog', and prints their name:\n\n    List\u003cDocument\u003e dogs = dbstore.getDocuments(database, \"Dog\");\n    for(Document dog : dogs) {\n        System.out.println(dog.getString(\"name\"));\n    }\n\nDocuments retrieved from the database contain metadata about attachments accessible via the Document#getAttachments() method.  To read the attachment content (stored as BLOB binary data in sqlite), use one of the getAttachment() or getAttachments() methods of DatabaseStore.  e.g. to fetch a dog image:\n\n    Attachment attachment = dbstore.getAttachment(dog, \"image.jpg\");\n    byte[] data = attachment.getContent();\n    Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);\n\nLicense\n-------\nsee LICENSE.txt\nCopyright 2011 2moro mobile\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnextfaze%2Fcouchdbsyncer-android","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnextfaze%2Fcouchdbsyncer-android","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnextfaze%2Fcouchdbsyncer-android/lists"}