Q:

Inheritance - Return extended class from parent class

I want to make a super class for database access called DataModel. I have also a SQLiteOpenHelper with generic methods. My problem is to convert the type of result on parent class. I will explain with generic code. Supose an all() method in parent class:
public class DataModel {
    public static ArrayList<DataModel> all(){
        ArrayList<DataModel> datos = new ArrayList<DataModel>();
        Map<String, String> columns = DataModel.getColumns();
        Map<String, Object> columnData = LocalStorageServices.DatabaseService().getAllMatchesFromTable(DataModel.getTableName(), columns);
        for (Map.Entry<String, Object> entry : columnData.entrySet()) {
            DataModel auxM = new DataModel(columns);
        }
    return datos;
    }
}

I have else an extended class:
public class User extends DataModel {
    protected String table = "testing";
}

What I need to achieve? To get a list of children instances in order to have the data and the concrete methods of the child. I mean, I would like to call ArrayList<User> appUsers = User.all(); but I cant because DataModel.all() returns a DataModel ArrayList (currently I would have to do ArrayList<DataModel> appUsers = User.all();).
The problem here is converting the typo for the children without knowing anything about the concrete child. Tomorrow I could create a new Entry class, Post class, or whatever model I want to create.

A:

You can make it generic e.g.
public class DataModel<T> {
        public ArrayList<T> all(){
            // do generic stuff
            return datos;
        }
    }

Does it have to be static? If yes, then you need to use 
public static <T> ArrayList<T> all() { ... }

This way your User class looks like this
public class User extends DataModel<User> {...}

and you can now use 
ArrayList<User> appUsers = User.all();

