vendredi 29 janvier 2016

android ormlite "attempt to re-open an already-closed object" error

I start a Service to get data from internet, then wrote the data to sqlite by ormlite. After finishing it, i stop the Service and close the DAO. Then re-open the app, it throws the exception "attempt to re-open an already-closed object". But i clear background apps and re-open, it works fine.

When the app starts, it will access location by gps, and get id in sqlite.

Sorry, my english is poor, thanks in advance

private int getIdWithCurrentCity(String city) {
    AreaDao areaDao = new AreaDao(this);
    try {
        return areaDao.queryByCity(city).get_id();
    } catch (SQLException e) {
        e.printStackTrace();
    } finally {
        areaDao.close();
    }
    return -1;
}

Aucun commentaire:

Enregistrer un commentaire