mardi 16 février 2016

Pull SQLite data to an array list

So I have been trying to use a cursorLoader but I can't seem to get around it. I have a database and I have my class set up. I have data stored in the SQLite database. I now want to be able to get all the data from that row (called location) and I want to store it in an array list so I can use it. The code for the CursorLoader is as follows :

@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {

    markerPoints = new ArrayList<LatLng>();

    switch (id) {
        case NOTES_LOADER: {
            return new CursorLoader(
                    this,                                           // Parent activity context
                    NotesProvider.CONTENT_URI,                      // Table to query
                    null,                                           // Projection to return
                    DBOpenHelper.NOTE_DATE + " = " + dateString,    // No selection clause
                    null,                                           // No selection arguments
                    null                                            // Default sort order
            );
        }

        case NOTES_LOCATION: {
            return new CursorLoader(
                    this,
                    NotesProvider.CONTENT_URI,
                    null,
                    DBOpenHelper.NOTE_LOCATION,
                    null,
                    null
            );
        }

        default: {
            // An invalid id was passed in
            return null;
        }
    }
}

@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
}

@Override
public void onLoaderReset(Loader<Cursor> loader) {
}

The tricky part is that the locations I want to load have to be from a specific day (NOTE_DATE). So the array list can only be from e.g. 2016-02-17. Once the day is picked then the locations will be saved to the array and then I can continue on with them. Any ideas?

Aucun commentaire:

Enregistrer un commentaire