title: Get cursor by using Realm library
body: <p>I am using cursor adapter for my list view. I was planning to use content resolvers to get a cursor. Now i changed my mind to give it a chance to learn Realm.</p>
  
  <p>How can i get <strong>"Cursor"</strong> object by using realm? By the way, i would also be appreciate give a few snippet to sort cursor.</p>
  
  <p>Thanks.</p>
  
  <pre><code>final class Contact extends RealmObject {
  
  private CharSequence mName;
  
  
  public CharSequence getName() {
      return mName;
  }
  
  public void setName(CharSequence name) {
      this.mName = name;
  }
  </code></pre>
  
  <p>}</p>
  
  <pre><code>final class ContactListAdapter extends CursorRecyclerViewAdapter&lt;ContactListAdapter.ContactHolder&gt; implements View.OnClickListener {
  
  private OnContactClickListener mListener;
  
  
  public ContactListAdapter(Context context, Cursor cursor) {
      super(context, cursor);
  }
  
  @Override
  public ContactHolder onCreateViewHolder(ViewGroup parent, int viewType) {
      View itemView = getLayoutInflater().inflate(R.layout.cell_contact, parent, false);
  
      ContactHolder contactHolder = new ContactHolder(itemView);
      contactHolder.mContactPhotoImageView.setOnClickListener(this);
  
      return contactHolder;
  }
  
  @Override
  public void onBindViewHolder(ContactHolder viewHolder, Cursor cursor) {
      viewHolder.mNameTextView.setText("Emre Akturk");
  
      int position = cursor.getPosition();
      viewHolder.mContactPhotoImageView.setImageResource(R.mipmap.ic_launcher);
      viewHolder.mContactPhotoImageView.setTag(position);
  }
  
  @Override
  public int getItemCount() {
      return 5;
  }
  
  public void setOnContactClickListener(OnContactClickListener callback) {
      this.mListener = callback;
  }
  
  @Override
  public void onClick(View v) {
      if (mListener == null) {
          return;
      }
  
      int position = (int) v.getTag();
      if (position == -1) {
          mListener.onContactCallClicked(v, getCursor(), position);
      } else {
          mListener.onContactAddClicked(v, position);
      }
  }
  
  public interface OnContactClickListener {
      void onContactCallClicked(View v, Cursor cursor, int position);
  
      void onContactAddClicked(View v, int position);
  }
  
  protected class ContactHolder extends RecyclerView.ViewHolder {
      private TextView mNameTextView;
      private CircleImageView mContactPhotoImageView;
  
      protected ContactHolder(View itemView) {
          super(itemView);
          mNameTextView = (TextView) itemView.findViewById(R.id.cell_contact_name_textview);
          mContactPhotoImageView = (CircleImageView) itemView.findViewById(R.id.cell_contact_photo_imageview);
      }
  }
  </code></pre>
  
  <p>}</p>