{"id":10266,"date":"2023-06-23T01:43:43","date_gmt":"2023-06-23T08:43:43","guid":{"rendered":"https:\/\/www.couchbase.com\/developers\/tutorials\/cblite-android-java-recyclerviews\/"},"modified":"2023-06-23T01:43:43","modified_gmt":"2023-06-23T08:43:43","slug":"cblite-android-java-recyclerviews","status":"publish","type":"tutorials","link":"https:\/\/www.couchbase.com\/es\/developers\/tutorials\/cblite-android-java-recyclerviews\/","title":{"rendered":"Tutorial Couchbase Lite with Recycler Views in Android with Java"},"content":{"rendered":"<h3 id=\"h-introduction\" class=\"wp-block-heading\">Introducci\u00f3n<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">En <a href=\"https:\/\/developer.android.com\/reference\/android\/support\/v7\/widget\/RecyclerView.html\">RecyclerView<\/a> widget is a popular option on the <a href=\"https:\/\/developer.android.com\">Android<\/a> platform for efficiently displaying dynamic data collections.\nThe data items feeding the RecyclerView may change as a result of user&#8217;s actions or with data fetched from the network.\nAs the name indicates, RecyclerViews <em>recycle<\/em> the views that correspond to the items in the data sets.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This tutorial will demonstrate how you can use<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/developer.couchbase.com\/documentation\/mobile\/2.0\/whatsnew.html\">Couchbase Lite 2.0<\/a> as a data source for RecyclerViews in your Android application.<\/li>\n\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">In this tutorial, we will be using <a href=\"https:\/\/developer.couchbase.com\/documentation\/mobile\/2.0\/couchbase-lite\/index.html\">Couchbase Lite<\/a> as a standalone, embedded data store within your mobile app.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can learn more about Couchbase Mobile <a href=\"https:\/\/developer.couchbase.com\/mobile\">aqu\u00ed<\/a><\/p>\n\n\n\n<h3 id=\"h-prerequisites\" class=\"wp-block-heading\">Requisitos previos<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\n<p>Android Studio 2.3 +<\/p>\n<ul>\n<li>Latest Version Downloadable from <a href=\"https:\/\/developer.android.com\/studio\/\">Android Developer Site<\/a><\/li>\n<\/ul>\n<\/li>\n\n\n<li>\n<p>git (Optional) \u00dfThis is required if you would prefer to pull the source code from GitHub repo.<\/p>\n<ul>\n<li>Create a <a href=\"https:\/\/github.com\">free github account<\/a> if you don&#8217;t already have one<\/li>\n<li>git can be downloaded from <a href=\"https:\/\/git-scm.com\/book\/en\/v2\/Getting-Started-Installing-Git\">git-scm.org<\/a><\/li>\n<\/ul>\n<\/li>\n\n\n<li>\n<p>Familiarity with the fundamentals of using Couchbase Lite on Android. If you need refresher, refer to our <a href=\"https:\/\/developer.couchbase.com\/documentation\/mobile\/2.0\/couchbase-lite\/java.html\">Getting Started with Android Java Guide<\/a>.<\/p>\n<\/li>\n\n\n<li>\n<p>Familiarity with the basics of <a href=\"https:\/\/developer.android.com\">Android app development apps<\/a> and with  <a href=\"https:\/\/developer.android.com\/guide\/topics\/ui\/layout\/recyclerview\">RecyclerViews<\/a>.<\/p>\n<\/li>\n\n<\/ul>\n\n\n\n<h3 id=\"h-installation\" class=\"wp-block-heading\">Installation<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">You have two options to download the App Source Code<\/p>\n\n\n\n<h4 id=\"h-option-1-git-clone\" class=\"wp-block-heading\">Option 1 : Git Clone<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Clone the <strong><em>master<\/em><\/strong> branch of the <code>UniversityLister<\/code> project from GitHub. Type the following command in your terminal<\/li>\n\n<\/ul>\n\n\n\n<pre class=\"wp-block-code language-shell\"><code>  git clone https:\/\/github.com\/couchbaselabs\/UniversityLister-Android.git\n<\/code><\/pre>\n\n\n\n<h4 id=\"h-option-2-download--zip\" class=\"wp-block-heading\">Option 2 : Download .zip<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Download the  <code>UniversityLister<\/code> project from <a href=\"https:\/\/github.com\/couchbaselabs\/UniversityLister-Android\/archive\/master.zip\">aqu\u00ed<\/a><\/li>\n\n<\/ul>\n\n\n\n<h3 id=\"h-app-overview\" class=\"wp-block-heading\">Resumen de la aplicaci\u00f3n<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">We will be working with a very simple &#8220;University Lister&#8221; app.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The app does the following:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>It displays a list of &#8220;university&#8221; items in a <code>Recyclerview<\/code> with <code>Couchbase Lite<\/code> as the data source.<\/li>\n\n\n<li>Every time a &#8220;University&#8221; entry is added to the Couchbase Lite database, the RecyclerView displaying the university items is automatically updated to include the newly added item<\/li>\n\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><img decoding=\"async\" src=\".\/recycler_view_app.gif\" alt=\"recycler_view_app\"><\/p>\n\n\n\n<h3 id=\"h-try-it-out\" class=\"wp-block-heading\">Try It Out<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Build and run the app in Android Studio.<\/li>\n\n\n<li>Tap on the &#8220;ADD UNIVERSITY&#8221; button.<\/li>\n\n\n<li>This will result in a new university item getting added to the RecyclerView.<\/li>\n\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Now let&#8217;s see how this works.<\/p>\n\n\n\n<h3 id=\"h-app-design\" class=\"wp-block-heading\">App Design<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">A typical design pattern for using Couchbase Lite as the data source for the RecyclerView in your app is shown below.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This also corresponds to the way we have implemented it in the sample app.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><img decoding=\"async\" src=\".\/app_design.png\" alt=\"app_design\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here are the key elements:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\n<p>En <em>RecyclerView<\/em> is instantiated by the <a href=\"https:\/\/developer.android.com\/reference\/android\/app\/Activity\"><em>Activity<\/em><\/a> and contains the <em>Adapter<\/em> .<\/p>\n<\/li>\n\n\n<li>\n<p>En <a href=\"https:\/\/developer.android.com\/reference\/android\/widget\/Adapter\"><em>Adapter<\/em><\/a> is responsible for binding the data items to the view using the <a href=\"https:\/\/developer.android.com\/reference\/android\/support\/v7\/widget\/RecyclerView.ViewHolder\"><strong>ViewHolder pattern<\/strong><\/a>.<\/p>\n<\/li>\n\n\n<li>\n<p><em>Couchbase Lite<\/em> is the data source for the data items that is used for populating the views.<\/p>\n<\/li>\n\n\n<li>\n<p>En <em>Database Manager<\/em> which is a singleton class is used for initialization and management of Couchbase Lite.<\/p>\n<\/li>\n\n\n<li>\n<p><a href=\"https:\/\/developer.couchbase.com\/documentation\/mobile\/2.0\/guides\/couchbase-lite\/native-api\/query\/index.html#live-query\">The Couchbase Lite Query<\/a> API for interacting with the database.<\/p>\n<\/li>\n\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">A Couchbase Lite Live Query allows an app to register for changes to the database that affect the results of the query using the <code>addChangeListener<\/code> call.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This is the sequence<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The Activity uses the Couchbase Lite Live Query to query for data items in the database and a listener is registered to handle query data updates.<\/li>\n\n\n<li>Every time the database gets updated with data that affects the query results, the Activity is notified of the changes via the listener callback.<\/li>\n\n\n<li>After retrieving the data from the Couchbase Lite database, the Adapter is notified of the changes.<\/li>\n\n\n<li>The RecyclerView is then updated with the updated data set.<\/li>\n\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><em>NOTE<\/em>: <em>How<\/em> the data gets into Couchbase Lite is not important in the context of this tutorial. In a real world app, the data in Couchbase Lite may be fetched from a remote server or may be updated as a result of the local user&#8217;s action. In our app, we manually insert a randomly created University document by clicking on the &#8220;ADD UNIVERSITY&#8221; button.<\/p>\n\n\n\n<h3 id=\"h-initialization\" class=\"wp-block-heading\">Initialization<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u00a1Abre! <em>ListActivity.java<\/em> archivo y local\u00edzalo <code>onCreate<\/code> method. This is where all the initialization takes place.<\/li>\n\n<\/ul>\n\n\n\n<pre class=\"wp-block-code language-java\"><code>@Override\nprotected void onCreate(Bundle savedInstanceState) {\n    super.onCreate(savedInstanceState);\n\n    \/\/ Initialize couchbase lite database manager\n    dbMgr = new DatabaseManager(this); \/\/ &lt;1&gt;\n\n    \/\/ Set content layout\n    setContentView(R.layout.activity_list); \/\/ &lt;2&gt;\n\n\n    \/\/ Set toolbar\n    Toolbar toolbar = (Toolbar) findViewById(R.id.university_toolbar);\n    setSupportActionBar(toolbar);\n\n    \/\/ Get recycler view\n    RecyclerView recyclerView = (RecyclerView)findViewById(R.id.rvUniversities);\n    recyclerView.setAdapter(adapter); \/\/ &lt;3&gt;\n    recyclerView.setLayoutManager(new LinearLayoutManager(this)); \n\n    \/\/ Asynchronously Load the data from local sample file\n    DataFetcher fetcher = new DataFetcher(this,this); \/\/&lt;4&gt;\n    fetcher.execute();\n}\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">&lt;1&gt; The <code>DatabaseManager<\/code> is instantiated. This is a singleton class that is responsible for creating\/opening instance of Couchbase Lite\n&lt;2&gt; The typical content layout initialization is handled here\n&lt;3&gt; The <code>RecyclerView<\/code> is configured with the <code>UniversityListAdapter<\/code> adapter and the appropriate Layout Manager.\n&lt;4&gt; The <code>DataFetcher<\/code> is instantiated. The DataFetcher is an android <code>AsyncTask<\/code> that is responsible for loading sample university data from a file bundled with the app. Think of it as simulating an external source for the data. We invoke the <code>execute()<\/code> method on the AsyncTask. More on this in the next section.<\/p>\n\n\n\n<h3 id=\"h-loading-sample-data\" class=\"wp-block-heading\">Loading Sample Data<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u00a1Abre! <strong>DataFetcher.java<\/strong> archivo y local\u00edzalo <code>doInBackground()<\/code> function, during Activity Launch, the <code>DataFetcher<\/code> class loads the sample university data from a local file bundled with the app. The loading of data is done on a background thread using <code>AsyncTask<\/code>.<\/li>\n\n<\/ul>\n\n\n\n<pre class=\"wp-block-code language-java\"><code>@Override\nprotected List&lt;University&gt; doInBackground(Void... voids) {\n    String fileName = &quot;university_sample.txt&quot;;\n    StringBuilder stringBuilder = new StringBuilder();\n    List&lt;University&gt; universities = null;\n    try {\n        \/\/ Load data from local sample data file\n        InputStream inputStream = mContext.getAssets().open(fileName); \/\/&lt;1&gt;\n        \/\/ use Jackson library to map the JSON to List of University POJO\n        ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); \/\/&lt;2&gt;\n        universities = Arrays.asList(mapper.readValue(inputStream, University[].class));\n        return universities;\n    } catch (IOException  e ) {\n        e.printStackTrace();\n        return null;\n    }\n}\n\n@Override\nprotected void onPostExecute(List&lt;University&gt; result) {\n    \/\/ Notify the IDataFetchResponse delegate (which in this case is ListActivity) of the availability of data\n    mDelegate.postResult(result);\n}\n<\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\">\n<li>The sample data is loaded from the <em>university-sample.txt<\/em> file in the assets folder. The content is in JSON format.<\/li>\n\n\n<li>Once the data is read, The JSON data is mapped to corresponding <code>University<\/code> POJO objects using the <a href=\"https:\/\/github.com\/FasterXML\/jackson\">Jackson library<\/a>.<\/li>\n\n\n<li><code>ListActivity<\/code> is then  notified of the completion of data load via the <code>IDataFetchResponse<\/code> interface.<\/li>\n\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Note<\/strong>: The sample data is <em>not<\/em> saved into the Couchbase Lite database at this point. It is in an in-memory data structure called <code>sampleData<\/code> en el <code>ListActivity<\/code> class. We will see how this sample data is used a little later in the tutorial.<\/p>\n\n\n\n<h3 id=\"h-loading-data-from-couchbase-lite-and-notifying-the-adapter\" class=\"wp-block-heading\">Loading Data from Couchbase Lite And Notifying the Adapter<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u00a1Abre! <strong>ListActivity.java<\/strong> file and locate to the <code>QueryForListOfUniversities()<\/code> method. This Activity sets up a &#8220;Live Query&#8221; to fetch the list of universities from the Couchbase Lite database. Initially, it will be empty.<\/li>\n\n<\/ul>\n\n\n\n<pre class=\"wp-block-code language-java\"><code>private void QueryForListOfUniversities() {\n    try {\n        \/\/ Create a liveQuery to fetch all documents from database\n        query = QueryBuilder.\n                select(SelectResult.all()).\n                from(DataSource.database(dbMgr.database)); \/\/&lt;1&gt;\n\n        \/\/ Add a live query listener to continually monitor for changes\n        query.addChangeListener(new QueryChangeListener() { \/\/&lt;2&gt;\n                @Override\n                    public void changed(QueryChange change) {\n                        ResultSet resultRows = change.getResults();\n                        Result row;\n                        List&lt;University&gt; universities = new ArrayList&lt;University&gt;();\n                        \/\/ Iterate over changed rows, corresponding documents and map to University POJO\n                        while ((row = resultRows.next()) != null) { \/\/&lt;3&gt;\n                            ObjectMapper objectMapper = new ObjectMapper();\n                            \/\/ Ignore undeclared properties\n                            objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);\n\n\n                            \/\/ Get dictionary value\n                            Dictionary valueMap = row.getDictionary(dbMgr.database.getName()); \/\/&lt;4&gt;\n\n                            \/\/ Convert from dictionary to corresponding University object\n                            University university = objectMapper.convertValue(valueMap.toMap(),University.class);\n                            universities.add(university); \/\/&lt;5&gt;\n                        }\n\n                        \/\/ Update the adapter with the newly added University documents\n                        adapter.setUniversities(universities); \/\/&lt;6&gt;\n\n                        runOnUiThread(new Runnable() {\n                            @Override\n                            public void run() {\n                                \/\/ 5. Notify adapter of changed data\n                                adapter.notifyDataSetChanged(); \/\/&lt;7&gt;\n                            }\n                        });\n\n                    }\n                }\n        );\n        \/\/ Run Query \n        query.execute(); \/\/&lt;8&gt;\n    }\n    catch (IllegalArgumentException e) {\n\n    } catch (CouchbaseLiteException e) {\n        e.printStackTrace();\n    }\n}\n<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\n<p>A Query is created ising the <a href=\"http:\/\/docs.couchbase.com\/mobile\/2.0\/couchbase-lite-java\/\">Query API<\/a> to fetch all documents from Couchbase Lite database. Typically you will use a <code>where<\/code> clause to filter the subset of documents to be fetched. But in our case, the database only holds the university documents so we just retrieve all of it.<\/p>\n<\/li>\n\n\n<li>\n<p>A query change listener is registered to listen to all database changes that impact the query. This makes the query &#8220;live&#8221;. As documents are added to the Couchbase Lite database, the activity will be asynchronously notified of the additions.<\/p>\n<\/li>\n\n\n<li>\n<p>In the listener callback, iterate over result set<\/p>\n<\/li>\n\n\n<li>\n<p>For every result, get the  <code>ReadOnlyDictionary<\/code> object correponding to the entry<\/p>\n<\/li>\n\n\n<li>\n<p>Convert from <code>ReadOnlyDictionary<\/code> type to University POJO using the <code>ObjectMapper<\/code> (from Jackson library)<\/p>\n<\/li>\n\n\n<li>\n<p>Update the adapter with the changed documents<\/p>\n<\/li>\n\n\n<li>\n<p>Notify the adapter of the updated data set that will cause the RecyclerView to be reloaded with the updated data<\/p>\n<\/li>\n\n\n<li>\n<p>Run the Query<\/p>\n<\/li>\n\n<\/ul>\n\n\n\n<h3 id=\"h-saving-to-couchbase-lite-and-triggering-database-change-updates\" class=\"wp-block-heading\">Saving to Couchbase Lite and Triggering Database Change Updates<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">In the &lt;Loading Sample Data&gt; section, we discussed how to load the sample university data  into an in-memory <code>sampleData<\/code> List data. This was intended to simulate the loading of data from an external source, like a web service for instance or a local user&#8217;s action.  Now, we discuss when and how that data is used.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u00a1Abre! <strong>ListActivity.java<\/strong> archivo y local\u00edzalo <code>fetchUniversityAndAddToDatabase()<\/code> method. The <code>fetchUniversityAndAddToDatabase()<\/code> method is invoked when the user taps on the &#8220;ADD UNIVERSITY&#8221; button in the app. In this method, we insert a data item from the sample data into Couchbase Lite.<\/li>\n\n<\/ul>\n\n\n\n<pre class=\"wp-block-code language-java\"><code>private void fetchUniversityAndAddToDatabase() {\n    Random r = new Random();\n    int index = r.nextInt(sampleData.size()-1);\n    try {\n        \/\/ Get university object at randomly selected index\n        University university = sampleData.get(index); \/\/&lt;1&gt;\n\n        \/\/ Construct the document from university object\n        ObjectMapper objectMapper = new ObjectMapper(); &lt;2&gt;\n\n        \/\/ Ignore undeclared properties\n        objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);\n\n        HashMap&lt;String,Object&gt; universityMap = objectMapper.convertValue(university,HashMap.class);\n        MutableDocument doc = new MutableDocument(universityMap);\n\n        \/\/ Save document to database.\n        dbMgr.database.save(doc); \/\/&lt;3&gt;\n    }\n    catch ( CouchbaseLiteException | NullPointerException e) {\n        e.printStackTrace();\n    }\n}\n<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A random entry from the <code>sampleData<\/code> List of <code>University<\/code> objects is selected<\/li>\n\n\n<li>En <code>Universty<\/code> object is converted to Couchbase Lite <code>Documento<\/code> using the <code>ObjectMapper<\/code> class of Jackson library<\/li>\n\n\n<li>En <code>Documento<\/code> is inserted into the database. This insertion triggers the Query listener to be invoked.<\/li>\n\n<\/ul>\n\n\n\n<h3 id=\"h-learn-more\" class=\"wp-block-heading\">M\u00e1s informaci\u00f3n<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u00a1Felicitaciones por haber completado este tutorial!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This tutorial walked you through an example of how to use Couchbase Lite database as an embedded data source for RecyclerViews within your Android app. We looked at a simple Query example. Check out the following links for further details on the Query API<\/p>\n\n\n\n<h3 id=\"h-further-reading\" class=\"wp-block-heading\">Leer m\u00e1s<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"http:\/\/docs.couchbase.com\/mobile\/2.0\/couchbase-lite-java\/\">Java API Reference<\/a><\/li>\n\n\n<li><a href=\"https:\/\/developer.couchbase.com\/documentation\/mobile\/2.0\/couchbase-lite\/java.html\">Getting Started with Couchbase Lite on Android<\/a><\/li>\n\n\n<li><a href=\"https:\/\/blog.couchbase.com\/sql-for-json-query-interface-couchbase-mobile\/\">Fundamentals of the Couchbase Lite 2.0 Query API<\/a><\/li>\n\n\n<li><a href=\"https:\/\/blog.couchbase.com\/querying-array-collections-couchbase-mobile\/\">Handling Arrays in Queries<\/a><\/li>\n\n\n<li><a href=\"https:\/\/blog.couchbase.com\/full-text-search-couchbase-mobile-2-0\/\">Couchbase Lite 2.0 Full Text Search API<\/a><\/li>\n\n\n<li><a href=\"https:\/\/blog.couchbase.com\/join-queries-couchbase-mobile\/\">Couchbase Lite 2.0 JOIN Query<\/a><\/li>\n\n<\/ul>","protected":false},"excerpt":{"rendered":"<p>Introduction The RecyclerView widget is a popular option on the Android platform for efficiently displaying dynamic data collections. The data items feeding the RecyclerView may change as a result of user&#8217;s actions or with data fetched from the network. As the name indicates, RecyclerViews recycle the views that correspond to the items in the data [&hellip;]<\/p>\n","protected":false},"author":0,"featured_media":0,"menu_order":0,"template":"","meta":{"_acf_changed":false,"inline_featured_image":false,"_acf":"","footnotes":""},"tutorial-languages":[595],"tutorial-tags":[587],"tutorial-technologies":[585,549],"tutorial-types":[555],"class_list":["post-10266","tutorials","type-tutorials","status-publish","hentry","tutorial-languages-android-java","tutorial-tags-android","tutorial-technologies-mobile","tutorial-technologies-query","tutorial-types-tutorial"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v28.8 (Yoast SEO v28.9) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Tutorial Couchbase Lite with Recycler Views in Android with Java - Couchbase<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.couchbase.com\/es\/developers\/tutorials\/cblite-android-java-recyclerviews\/\" \/>\n<meta property=\"og:locale\" content=\"es_MX\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Tutorial Couchbase Lite with Recycler Views in Android with Java\" \/>\n<meta property=\"og:description\" content=\"Introduction The RecyclerView widget is a popular option on the Android platform for efficiently displaying dynamic data collections. The data items feeding the RecyclerView may change as a result of user&#8217;s actions or with data fetched from the network. As the name indicates, RecyclerViews recycle the views that correspond to the items in the data [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.couchbase.com\/es\/developers\/tutorials\/cblite-android-java-recyclerviews\/\" \/>\n<meta property=\"og:site_name\" content=\"Couchbase\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/Couchbase\/\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.couchbase.com\/wp-content\/uploads\/2026\/10\/Cloud-2.png\" \/>\n\t<meta property=\"og:image:width\" content=\"2548\" \/>\n\t<meta property=\"og:image:height\" content=\"1171\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:site\" content=\"@couchbase\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"9 minutos\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/es\\\/developers\\\/tutorials\\\/cblite-android-java-recyclerviews\\\/\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/es\\\/developers\\\/tutorials\\\/cblite-android-java-recyclerviews\\\/\",\"name\":\"Tutorial Couchbase Lite with Recycler Views in Android with Java - Couchbase\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/es\\\/#website\"},\"datePublished\":\"2023-06-23T08:43:43+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/es\\\/developers\\\/tutorials\\\/cblite-android-java-recyclerviews\\\/#breadcrumb\"},\"inLanguage\":\"es\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.couchbase.com\\\/es\\\/developers\\\/tutorials\\\/cblite-android-java-recyclerviews\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/es\\\/developers\\\/tutorials\\\/cblite-android-java-recyclerviews\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.couchbase.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Tutorial Couchbase Lite with Recycler Views in Android with Java\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/es\\\/#website\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/es\\\/\",\"name\":\"Couchbase\",\"description\":\"The Operational Data Platform for AI\u2122\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/es\\\/#organization\"},\"alternateName\":\"Couchbase, Inc.\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.couchbase.com\\\/es\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"es\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/es\\\/#organization\",\"name\":\"Couchbase\",\"alternateName\":\"Couchbase, Inc.\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/es\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"es\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/es\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/Couchbase_Logo_Couchbase_Token_Red-1.png\",\"contentUrl\":\"https:\\\/\\\/www.couchbase.com\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/Couchbase_Logo_Couchbase_Token_Red-1.png\",\"width\":1129,\"height\":1129,\"caption\":\"Couchbase\"},\"image\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/es\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/Couchbase\\\/\",\"https:\\\/\\\/x.com\\\/couchbase\",\"https:\\\/\\\/www.youtube.com\\\/c\\\/CouchbaseServer\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/couchbase\\\/\",\"https:\\\/\\\/github.com\\\/couchbase\\\/\",\"https:\\\/\\\/en.wikipedia.org\\\/wiki\\\/Couchbase,_Inc.\"],\"description\":\"Couchbase is a database software company headquartered in San Jose, California, providing an operational data platform for AI used by hundreds of global enterprises.\",\"legalName\":\"Couchbase, Inc.\",\"foundingDate\":\"2011-01-01\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Tutorial Couchbase Lite with Recycler Views in Android with Java - Couchbase","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.couchbase.com\/es\/developers\/tutorials\/cblite-android-java-recyclerviews\/","og_locale":"es_MX","og_type":"article","og_title":"Tutorial Couchbase Lite with Recycler Views in Android with Java","og_description":"Introduction The RecyclerView widget is a popular option on the Android platform for efficiently displaying dynamic data collections. The data items feeding the RecyclerView may change as a result of user&#8217;s actions or with data fetched from the network. As the name indicates, RecyclerViews recycle the views that correspond to the items in the data [&hellip;]","og_url":"https:\/\/www.couchbase.com\/es\/developers\/tutorials\/cblite-android-java-recyclerviews\/","og_site_name":"Couchbase","article_publisher":"https:\/\/www.facebook.com\/Couchbase\/","og_image":[{"width":2548,"height":1171,"url":"https:\/\/www.couchbase.com\/wp-content\/uploads\/2026\/10\/Cloud-2.png","type":"image\/png"}],"twitter_card":"summary_large_image","twitter_site":"@couchbase","twitter_misc":{"Est. reading time":"9 minutos"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.couchbase.com\/es\/developers\/tutorials\/cblite-android-java-recyclerviews\/","url":"https:\/\/www.couchbase.com\/es\/developers\/tutorials\/cblite-android-java-recyclerviews\/","name":"Tutorial Couchbase Lite with Recycler Views in Android with Java - Couchbase","isPartOf":{"@id":"https:\/\/www.couchbase.com\/es\/#website"},"datePublished":"2023-06-23T08:43:43+00:00","breadcrumb":{"@id":"https:\/\/www.couchbase.com\/es\/developers\/tutorials\/cblite-android-java-recyclerviews\/#breadcrumb"},"inLanguage":"es","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.couchbase.com\/es\/developers\/tutorials\/cblite-android-java-recyclerviews\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.couchbase.com\/es\/developers\/tutorials\/cblite-android-java-recyclerviews\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.couchbase.com\/"},{"@type":"ListItem","position":2,"name":"Tutorial Couchbase Lite with Recycler Views in Android with Java"}]},{"@type":"WebSite","@id":"https:\/\/www.couchbase.com\/es\/#website","url":"https:\/\/www.couchbase.com\/es\/","name":"Couchbase","description":"The Operational Data Platform for AI\u2122","publisher":{"@id":"https:\/\/www.couchbase.com\/es\/#organization"},"alternateName":"Couchbase, Inc.","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.couchbase.com\/es\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"es"},{"@type":"Organization","@id":"https:\/\/www.couchbase.com\/es\/#organization","name":"Couchbase","alternateName":"Couchbase, Inc.","url":"https:\/\/www.couchbase.com\/es\/","logo":{"@type":"ImageObject","inLanguage":"es","@id":"https:\/\/www.couchbase.com\/es\/#\/schema\/logo\/image\/","url":"https:\/\/www.couchbase.com\/wp-content\/uploads\/2026\/11\/Couchbase_Logo_Couchbase_Token_Red-1.png","contentUrl":"https:\/\/www.couchbase.com\/wp-content\/uploads\/2026\/11\/Couchbase_Logo_Couchbase_Token_Red-1.png","width":1129,"height":1129,"caption":"Couchbase"},"image":{"@id":"https:\/\/www.couchbase.com\/es\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/Couchbase\/","https:\/\/x.com\/couchbase","https:\/\/www.youtube.com\/c\/CouchbaseServer","https:\/\/www.linkedin.com\/company\/couchbase\/","https:\/\/github.com\/couchbase\/","https:\/\/en.wikipedia.org\/wiki\/Couchbase,_Inc."],"description":"Couchbase es una empresa de software de bases de datos con sede en San Jos\u00e9, California, que proporciona una plataforma de datos operativa para la inteligencia artificial utilizada por cientos de empresas globales.","legalName":"Couchbase, Inc.","foundingDate":"2011-01-01"}]}},"acf":[],"permalink_manager":null,"_links":{"self":[{"href":"https:\/\/www.couchbase.com\/es\/wp-json\/wp\/v2\/tutorials\/10266","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.couchbase.com\/es\/wp-json\/wp\/v2\/tutorials"}],"about":[{"href":"https:\/\/www.couchbase.com\/es\/wp-json\/wp\/v2\/types\/tutorials"}],"version-history":[{"count":0,"href":"https:\/\/www.couchbase.com\/es\/wp-json\/wp\/v2\/tutorials\/10266\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.couchbase.com\/es\/wp-json\/wp\/v2\/media?parent=10266"}],"wp:term":[{"taxonomy":"tutorial-languages","embeddable":true,"href":"https:\/\/www.couchbase.com\/es\/wp-json\/wp\/v2\/tutorial-languages?post=10266"},{"taxonomy":"tutorial-tags","embeddable":true,"href":"https:\/\/www.couchbase.com\/es\/wp-json\/wp\/v2\/tutorial-tags?post=10266"},{"taxonomy":"tutorial-technologies","embeddable":true,"href":"https:\/\/www.couchbase.com\/es\/wp-json\/wp\/v2\/tutorial-technologies?post=10266"},{"taxonomy":"tutorial-types","embeddable":true,"href":"https:\/\/www.couchbase.com\/es\/wp-json\/wp\/v2\/tutorial-types?post=10266"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}