I am a bit confused on how to retrieve the title and snippet that i have saved in my SQLite database. I saved the title and snippet and can see it in my database, but am not entirely sure on how to retrieve the information needed.
So this is how i save my title and snippet:
contentValues.put(LocationsDB.FIELD_TITLE, title.getText().toString());
contentValues.put(LocationsDB.FIELD_SNIPPET, snippet.getText().toString());
So with this i can see (with accessing the database) that the title and snippet is saved. Now my question is how can i retrieve that information?
I can retieve the latlng values as well as the zoom level, but don't know how to get the title and snippet:
loading the latlng values and zoom level:
Marker marker;
......
@Override
public void onLoadFinished(Loader<Cursor> arg0, Cursor arg1) {
int locationCount = 0;
double lat=0;
double lng=0;
float zoom=0;
float title = 0; \\Don't know if this part is correct..with warning "The value of the local variable title is not used"
float snippet = 0; \\Don't know if this part is correct ..with warning "The value of the local variable title is not used"
locationCount = arg1.getCount();
arg1.moveToFirst();
for(int i=0;i<locationCount;i++){
lat = arg1.getDouble(arg1.getColumnIndex(LocationsDB.FIELD_LAT));
lng = arg1.getDouble(arg1.getColumnIndex(LocationsDB.FIELD_LNG));
zoom = arg1.getFloat(arg1.getColumnIndex(LocationsDB.FIELD_ZOOM));
title = arg1.getFloat(arg1.getColumnIndex(LocationsDB.FIELD_TITLE));
snippet = arg1.getFloat(arg1.getColumnIndex(LocationsDB.FIELD_SNIPPET));
point = new LatLng(lat, lng);
drawMarker(point);
arg1.moveToNext();
}
if(locationCount>0){
googleMap.moveCamera(CameraUpdateFactory.newLatLng(new LatLng(lat,lng)));
googleMap.animateCamera(CameraUpdateFactory.zoomTo(zoom));
TextView titleText = (TextView) v.findViewById(R.id.TitleId);
titleText.setText(marker.getTitle());
TextView snippetText = (TextView) v.findViewById(R.id.SnippetId);
snippetText.setText(marker.getSnippet());
Doing this the app just then crashes? Am really hoping someone could help me and explain what i am doing wrong
Aucun commentaire:
Enregistrer un commentaire