jeudi 1 janvier 2015

Saving data to SQlite Database

I would like to know (as i am new to SQlite Database) what i need to do to save data to Sqlite. The problem i am having is that in my app the user can take an image via camera intent and return that image to the map (Google Map API v2). The image is then displayed full screen as the user taps on the marker. Now obviously I need to save those markers to the map so when the user returns to the app the markers (and relevant images) are there. Now i have tried to save the image to the database as a blob, but it doesn't seem to work (i am not entirely sure why, i can provide code is necessary). But i was thinking do i need to save the image (as the image is already saved on the sdCard as soon as the photo is taken) or do i just save the markerId (HashMap) of that marker to point to the relevant image taken at that point (marker)?


This is what i have to retrieve the image for that marker when tapped on the marker:



private Map<String, Bitmap> myMarkersHash;
private String markerId;


then in onCreate Method:



myMarkersHash = new HashMap<String, Bitmap>();


for when adding the marker:



private void drawMarker(LatLng point) {
Marker marker = googleMap.addMarker(new MarkerOptions()
.position(thePoint));
markerId = marker.getId();


And then when displaying the image:



ImageView markerIcon = (ImageView) v.findViewById(R.id.marker_icon);
Bitmap bitmap = myMarkersHash.get(marker.getId());
markerIcon.setImageBitmap(bitmap);


Any help and advise would be greatly appreciated!


Thanks!


Aucun commentaire:

Enregistrer un commentaire