title: Displaying data in a RecyclerView
body: <p>I have this working perfectly with a ListView, but decided to update my code to use RecyclerView.</p>
  
  <p>I see there is no default implementation, and the responses to similar questions are quite old.</p>
  
  <p>Is using a sort of cursor the best way to go, or is there a better option?</p>
  
  <p>These are my code snippets for a working RecyclerView with hard-coded values:</p>
  
  <p><strong>MainActivity</strong></p>
  
  <pre><code>    recyclerView = (RecyclerView)findViewById(R.id.recycler_view);
      mLayoutmanager = new LinearLayoutManager(this);
      recyclerView.setLayoutManager(mLayoutmanager);
  
      mAdapter = new recyclerViewDataAdapter();
      recyclerView.setAdapter(mAdapter);
  </code></pre>
  
  <p><strong>recyclerViewDataAdapter</strong></p>
  
  <pre><code>public class recyclerViewDataAdapter extends RecyclerView.Adapter {
  
      @Override
      public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
  
          //lets populate our recyler view with the item created;
          //get the view from the layout inflator
          //  third parameter is set to false to prevent viewgroup to attach to root
          View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.recycler_item,parent,false);
  
          // as this method need to return the viewHolder type
          // need to convert our view to the view holder
          RecyclerView.ViewHolder viewHolder = new RecyclerView.ViewHolder(view) {
              @Override
              public String toString() {
                  return super.toString();
              }
          };
          return viewHolder;
      }
  
      @Override
      public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
  
      }
  
      @Override
      public int getItemCount() {
          return 3000;
      }
  }
  </code></pre>
  
  <p><strong>activity_main</strong></p>
  
  <pre><code>&lt;android.support.v7.widget.RecyclerView
              android:id="@+id/recycler_view"
              android:scrollbars="vertical"
              android:layout_width="match_parent"
              android:layout_height="match_parent"/&gt;
  </code></pre>
  
  <p><strong>recycler_item</strong></p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_marginTop="10dp"
      android:orientation="vertical"&gt;
  
      &lt;TextView
          android:id="@+id/textView"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:text="Hii "
          android:textSize="30sp" /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Here is my DatabaseAdapter which worked perfectly with a ListView:</p>
  
  <pre><code>public class DatabaseHelper extends SQLiteAssetHelper {
  
      private static final int DATABASE_VERSION = 1;
  
      private static final String DATABASE_NAME = "database9.db";
      private static final String BOOKS = "books";
      private static final String AUTHORS = "authors";
  
      public DatabaseHelper (Context context) {
          super(context, DATABASE_NAME, null, DATABASE_VERSION);
          // setForcedUpgrade();
      }
  
      // Getting all books
      public ArrayList&lt;Author&gt; getAllAuthors() {
  
          ArrayList&lt;Author&gt; authorList = new ArrayList&lt;&gt;();
  
          // Select all query
          String selectQuery = "SELECT id, name FROM " + AUTHORS + " ORDER BY name_alphabetic";
  
          SQLiteDatabase db = this.getWritableDatabase();
          Cursor cursor = db.rawQuery(selectQuery, null);
  
          // looping through all rows and adding to list
          if (cursor.moveToFirst()) {
              do {
                  // create new author object
                  Author author = new Author();
                  // set ID and name of author object
                  author.setID(Integer.parseInt(cursor.getString(0)));
                  author.setName(cursor.getString(1));
                  // pass author object to authorList array
                  authorList.add(author);
              } while (cursor.moveToNext());
          }
  
          // return author list
          return authorList;
      }
  }
  </code></pre>