How can I can i feed a looping data from my local database into recycler view in android.
I have three classes,
ItemData.java
public class NatureItem {
    private String title;
    private int imageUrl;
    public NatureItem(String title,int imageUrl){
    this.title = title;
    this.imageUrl = imageUrl;
    }
    public String getTitle() {
    return title;
    }
    public void setTitle(String title) {
    this.title = title;
    }
    public int getImageUrl() {
    return imageUrl;
    }
    public void setImageUrl(int imageUrl) {
    this.imageUrl = imageUrl;
    }
}
CardAdapter.java
public class CardAdapter extends RecyclerView.Adapter<CardAdapter.ViewHolder> {
     private NatureItem[] itemsData;
     public CardAdapter(NatureItem[] itemsData) {
     this.itemsData = itemsData;
     }
    // Create new views (invoked by the layout manager)
    @Override
    public CardAdapter.ViewHolder onCreateViewHolder(ViewGroup parent,
                                                   int viewType) {
        // create a new view
        View itemLayoutView = LayoutInflater.from(parent.getContext())
                               .inflate(R.layout.list_cardview_activity, null);
        // create ViewHolder
        ViewHolder viewHolder = new ViewHolder(itemLayoutView);
        return viewHolder;
    }
    // Replace the contents of a view (invoked by the layout manager)
    @Override
    public void onBindViewHolder(ViewHolder viewHolder, int position) {
        // - get data from your itemsData at this position
        // - replace the contents of the view with that itemsData
        viewHolder.txtViewTitle.setText(itemsData[position].getTitle());
        viewHolder.imgViewIcon.setImageResource(itemsData[position].getImageUrl());
    }
    // inner class to hold a reference to each item of RecyclerView
    public static class ViewHolder extends RecyclerView.ViewHolder {
        public TextView txtViewTitle;
        public ImageView imgViewIcon;
        public ViewHolder(View itemLayoutView) {
            super(itemLayoutView);
            txtViewTitle = (TextView) itemLayoutView.findViewById(R.id.blog_content);
            imgViewIcon = (ImageView) itemLayoutView.findViewById(R.id.imageView);
        }
    }
    // Return the size of your itemsData (invoked by the layout manager)
    @Override
    public int getItemCount() {
         return itemsData.length; 
    }
}
MainActivity.java
     NatureItem itemsData[] ={ 
                new NatureItem("imageName",R.drawable.image2),
                new NatureItem("imageName2",R.drawable.image2)              
        };
    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view);       
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    mAdapter = new CardAdapter(itemsData);
    recyclerView.setAdapter(mAdapter);
    recyclerView.setItemAnimator(new DefaultItemAnimator());
With the above codes I am able to populate my recycleview with the information in the array above(itemsData).
Now, I want to be able to populate my recycleview with data from my local sql database using the database handler below;
public class DatabaseHandler extends SQLiteOpenHelper {
    // Creating Tables
    @Override
    public void onCreate(SQLiteDatabase db) {
        String CREATE_LOGIN_TABLE = "CREATE TABLE " + TABLE_LOGIN + "("
                + KEY_ID + " INTEGER PRIMARY KEY,"
                + KEY_FIRSTNAME + " TEXT,"
                + KEY_LASTNAME + " TEXT,"
                + KEY_EMAIL + " TEXT UNIQUE,"
                + KEY_UID + " TEXT,"
                + KEY_CREATED_AT + " TEXT" + ")";
        db.execSQL(CREATE_LOGIN_TABLE);
    }
    /**
     * Getting user data from database
     * */
    public Cursor  getUserDetails(){
        HashMap<String,String> user = new HashMap<String,String>();
             String selectQuery = "SELECT  * FROM " + TABLE_LOGIN;
             SQLiteDatabase db = this.getReadableDatabase();
             Cursor cursor = db.rawQuery(selectQuery, null);
            if (cursor!=null){
                 user.put("fname", cursor.getString(1));
                 user.put("lname", cursor.getString(2));
                 user.put("email", cursor.getString(3));
                 user.put("uid", cursor.getString(4));
                 user.put("created_at", cursor.getString(5));
                cursor.moveToNext();
            }
            return cursor;
    }
    /**
     * Getting user status
     * return true if rows are there in table
     * */
    public int getRowCount() {
        String countQuery = "SELECT  * FROM " + TABLE_LOGIN;
        SQLiteDatabase db = this.getReadableDatabase();
        Cursor cursor = db.rawQuery(countQuery, null);
        int rowCount = cursor.getCount();
        db.close();
        cursor.close();
        // return row count
        return rowCount;
    }
}
Please how can I populate my recyclerview with the data from the database handler. I would be grateful if somebody could help. Thanks in advance