@@ -214,7 +214,24 @@ protected void onCreate(Bundle savedInstanceState) {
214
214
* Also, the default layout is excluded and the 'osmtracker' tag is added by default.
215
215
*/
216
216
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
+
217
231
StringBuilder tags = new StringBuilder ();
232
+
233
+ tags .append (previouslySavedTags );
234
+
218
235
ArrayList <String > fixedTags = new ArrayList <String >();
219
236
220
237
//covert the file name to simple layout name
@@ -232,9 +249,6 @@ private void saveTagsForTrack(){
232
249
tags .append (simpleName ).append ("," );
233
250
}
234
251
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 ();
238
252
239
253
//set the values tag and update the table
240
254
values .put (TrackContentProvider .Schema .COL_TAGS , tags .toString ());
0 commit comments