Greetings I have 2 databases in the first 100 points and this is a list of chapters, in the second more than 250 are the contents of the chapters, I need to distribute these 250 into 100 chapters. For example, in the first chapter 3 items of the contents of the chapters, in the second 1, and thus a different number in different chapters. I can not understand the algorithm for such processing. My adapter returns the length of the database array, how do I properly distribute in the ratio I need? 
Addition:
DB class:
class HeadsSQLiteOpenHelper extends SQLiteOpenHelper { private static final int mDBVersion = 1; private static final String mDBName = "MYTESTDB"; private static final String mTableName = "TEST_TABLE"; private static final String mId = "_id"; private static final String mLINE1 = "LINE1"; private static final String mLINE2 = "LINE2"; private static final String[] myColumns = {mId, mLINE1, mLINE2}; private static final String myTable = "CREATE TABLE " + mTableName + "(" + mId + " INTEGER PRIMARY KEY AUTOINCREMENT, " + mLINE1 + " TEXT, " + mLINE2 + " TEXT)"; HeadsSQLiteOpenHelper(Context context) { super(context, mDBName, null, mDBVersion); } @Override public void onCreate(SQLiteDatabase db) { db.execSQL(myTable); } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { db.execSQL("DROP TABLE IF EXISTS " + mTableName); this.onCreate(db); } List<Heads> getHeadsItem(){ SQLiteDatabase db = this.getReadableDatabase(); @SuppressLint("Recycle") Cursor cursor = db.query(mTableName, // a. table myColumns, null, null, null, null, null, null); List<Heads> headsItem = new ArrayList<>(); if(cursor.moveToFirst()){ while(!cursor.isAfterLast()){ headsItem.add(new Heads( cursor.getString(cursor.getColumnIndex(mLINE1)), cursor.getString(cursor.getColumnIndex(mLINE2)))); cursor.moveToNext(); } } return headsItem; } Adapter class:
class TheHeadsAdapter extends RecyclerView.Adapter<TheHeadsAdapter.ViewHolder> { private List<Heads> mHeads; TheHeadsAdapter(List<Heads> headsItem) { this.mHeads = headsItem; } @Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View itemView = LayoutInflater.from(parent.getContext()).inflate( R.layout.head_items, parent, false); return new ViewHolder(itemView); } @Override public void onBindViewHolder(final ViewHolder viewHolder, final int position) { viewHolder.line1.setText(Html.fromHtml(mHeads.get(position).getLine1())); viewHolder.line2.setText(Html.fromHtml(mHeads.get(position).getLine2())); } @Override public int getItemCount() { return mHeads.size(); } static class ViewHolder extends RecyclerView.ViewHolder { TextView line1, line2; ViewHolder(View itemView) { super(itemView); line1 = (TextView) itemView.findViewById(R.id.line1); line2 = (TextView) itemView.findViewById(R.id.line2); } } Thus, the method
public int getItemCount() { return mHeads.size(); } Returns the entire length of positions from the database to the specified RecyclerView and this is a list of chapters where there are 100 positions. Now the task is that I can, in each of these positions, load the amount I need from another similar adapter. For example, in 1 position of chapters 3 positions of the contents of chapters, in 2 - 5, in 3 - 2, and thus they differ.