protected List<T> getList(String[] projection, String selection, String[] selectionArgs,
                              String sortOrder, Integer limit) {
        List<T> rows = new ArrayList<>();
        //noinspection TryWithIdenticalCatches
        try {
            Cursor c = mCr.query(mUri, projection, selection, selectionArgs, sortOrder);
            if (c != null) {
                if (c.moveToFirst()) {
                    int i = 0;
                    Constructor<T> constructor =
                        mTableRowClass.getConstructor(this.getClass(), Cursor.class);
                    do {
                        rows.add(constructor.newInstance(this, c));
                        i++;
                    } while ((limit == null || limit > i) && c.moveToNext());
                }
                c.close();
            }
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
            // We don't want to pass the exceptions up or rethrow a more generic exception, since
            // then, we would have to handle this on every object instantiation, but these
            // exceptions should never throw in production, since these are static code issues
            // (wrongly defined classes) which should be handled once, straight away and then
            // never change again.
            System.exit(-1);
        } catch (InstantiationException e) {
            e.printStackTrace();
            System.exit(-1);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
            System.exit(-1);
        } catch (InvocationTargetException e) {
            e.printStackTrace();
            System.exit(-1);
        }
        return rows;
    }
protected List<T> getList(String[] projection, String selection, String[] selectionArgs,
                              String sortOrder, Integer limit) {
        List<T> rows = new ArrayList<>();
       
        try {
            Cursor c = mCr.query(mUri, projection, selection, selectionArgs, sortOrder);
            if (c != null) {
                if (c.moveToFirst()) {
                    int i = 0;
                    Constructor<T> constructor =
                        mTableRowClass.getConstructor(this.getClass(), Cursor.class);
                    do {
                        rows.add(constructor.newInstance(this, c));
                        i++;
                    } while ((limit == null || limit > i) && c.moveToNext());
                }
                c.close();
            }
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
           
           
           
           
           
            System.exit(-1);
        } catch (InstantiationException e) {
            e.printStackTrace();
            System.exit(-1);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
            System.exit(-1);
        } catch (InvocationTargetException e) {
            e.printStackTrace();
            System.exit(-1);
        }
        return rows;
    }
protected list<t> getlist(string[] projection, string selection, string[] selectionargs, string sortorder, integer limit) { list<t> rows = new arraylist<>(); try { cursor c = mcr.query(muri, projection, selection, selectionargs, sortorder); if (c != null) { if (c.movetofirst()) { int i = 0; constructor<t> constructor = mtablerowclass.getconstructor(this.getclass(), cursor.class); do { rows.add(constructor.newinstance(this, c)); i++; } while ((limit == null || limit > i) && c.movetonext()); } c.close(); } } catch (nosuchmethodexception e) { e.printstacktrace(); system.exit(-1); } catch (instantiationexception e) { e.printstacktrace(); system.exit(-1); } catch (illegalaccessexception e) { e.printstacktrace(); system.exit(-1); } catch (invocationtargetexception e) { e.printstacktrace(); system.exit(-1); } return rows; }