1

When selecting a model using DBFlow (SQLite.select().from(Schedule.class).where(Schedule_Table.id.eq(scheduleId)).querySingle()) I get the following error:

unable to open database file (code 2062)

########################################################### Error Code : 2062 (SQLITE_CANTOPEN_EMFILE) Caused By : Application has

opened two many files. Maximum of available file descriptors in one process is 1024 in default. (unable to open database file (code 2062))

#

Is it something I am doing wrong or is this a bug in the DBFlow library? The code of DBFlow that crashes is:

@SuppressWarnings("unchecked")
@Nullable
public TModel convertToData(@NonNull final FlowCursor cursor, @Nullable TModel data,
                            boolean moveToFirst) {
    if (!moveToFirst || cursor.moveToFirst()) {
        if (data == null) {
            data = getInstanceAdapter().newInstance();
        }
        getInstanceAdapter().loadFromCursor(cursor, data);
    }
    return data;
}

this function gets executed by the following function, here you can see the cursor is getting closed:

@Nullable
public TReturn load(@Nullable FlowCursor cursor, @Nullable TReturn data) {
    if (cursor != null) {
        try {
            data = convertToData(cursor, data);
        } finally {
            cursor.close();
        }
    }
    return data;
}

Since the cursor is getting closed, what could be the possible error that too many files are opened?

Bart Bergmans
  • 4,061
  • 3
  • 28
  • 56

0 Answers0