Saving data in SQLite
To connect SQLite to the and to save the data in SQLite, implement the activity LoaderManager.LoaderCallbacks<Cursor> and instatiate the datasource in the onCreate method:
mDataSource = new MemoriesDataSource(this); getLoaderManager().initLoader(0,null,this);
Implement the callback methods for the LoaderManager.LoaderCallbacks<Cursor> interface:
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
return null;
}
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
}
@Override
public void onLoaderReset(Loader<Cursor> loader) {
}Now, refactor the addingMarker code in a method as follows:
private void addMarker(Memory memory) {
Marker marker = mMap.addMarker(new MarkerOptions()
.draggable(true)
.position(new LatLng(memory.latitude, memory.longitude)));
mMemories.put(marker.getId(), memory);
}We still need to work with dragging the marker for future implementation...