Skip to content Skip to sidebar Skip to footer

How To Use A Get Method For A Sqlite Database Management Class In Another Class?

What I am trying to do is retrieve an ArrayList from another database manager class. Unfortunately all I can do because the manager class cannot work statically is create an instan

Solution 1:

Your code is a bit confusing... In each iteration of the while loop, you are incrementing the cursor (names.moveToNext()); You are also incrementing go.

The result would be:

1st iteration: You are taking the data from the first column of the first query

2nd iteration: You are taking the data from the second column of the second query

etc...

I'm assume that you want to be reading data from the same column of the database for each iteration.

try this:

public ArrayList<Inputted> getListOfAssignments (SQLiteDatabase db) {
    Cursor names = getAssignmentNames(db);
    ArrayList<Inputted> assList = new ArrayList<Inputted>();

    names.moveToFirst();
    columnContainingStringToSendToInputtedConstructor = x;  //replace the x with column you need from your tablewhile (!names.isAfterLast()) {
        assList.add(new Inputted(names.getString(columnContainingStringToSendToInputtedConstructor));

        names.moveToNext();
    }
}

Post a Comment for "How To Use A Get Method For A Sqlite Database Management Class In Another Class?"