Skip to content

Commit fa2dfe3

Browse files
authored
Merge pull request #176 from aton1698/Issue170
The bug that deletes the saved tags before save the trace is solved
2 parents 340ccc6 + a25cc2a commit fa2dfe3

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

app/src/main/java/net/osmtracker/activity/TrackLogger.java

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,24 @@ protected void onCreate(Bundle savedInstanceState) {
214214
* Also, the default layout is excluded and the 'osmtracker' tag is added by default.
215215
*/
216216
private void saveTagsForTrack(){
217+
//obtain the current track id and initialize the values variable
218+
Uri trackUri = ContentUris.withAppendedId(TrackContentProvider.CONTENT_URI_TRACK, currentTrackId);
219+
ContentValues values = new ContentValues();
220+
221+
//Checking for previously saved tags
222+
Cursor cursor = getContentResolver().query( trackUri, null, null, null, null);
223+
StringBuilder previouslySavedTags = new StringBuilder();
224+
int index = cursor.getColumnIndex(TrackContentProvider.Schema.COL_TAGS);
225+
226+
while (cursor.moveToNext()) {
227+
if(cursor.getString(index) != null)
228+
previouslySavedTags.append(cursor.getString(index) + ",");
229+
}
230+
217231
StringBuilder tags = new StringBuilder();
232+
233+
tags.append(previouslySavedTags);
234+
218235
ArrayList<String> fixedTags = new ArrayList<String>();
219236

220237
//covert the file name to simple layout name
@@ -232,9 +249,6 @@ private void saveTagsForTrack(){
232249
tags.append(simpleName).append(",");
233250
}
234251

235-
//obtain the current track id and initialize the values variable
236-
Uri trackUri = ContentUris.withAppendedId(TrackContentProvider.CONTENT_URI_TRACK, currentTrackId);
237-
ContentValues values = new ContentValues();
238252

239253
//set the values tag and update the table
240254
values.put(TrackContentProvider.Schema.COL_TAGS, tags.toString());

0 commit comments

Comments
 (0)