Code example for Uri

Methods: getLastPathSegment

		if (id == -1) {
			// We need to create a new playlist. 
			ContentValues values = new ContentValues(1);
			values.put(MediaStore.Audio.Playlists.NAME, name);
			Uri uri = resolver.insert(MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI, values);
			id = Long.parseLong(uri.getLastPathSegment());
		} else { 
			// We are overwriting an existing playlist. Clear existing songs. 
			Uri uri = MediaStore.Audio.Playlists.Members.getContentUri("external", id);
			resolver.delete(uri, null, null);
		return id;
	 * Run the given query and add the results to the given playlist. Should be 
	 * run on a background thread. 
	 * @param resolver A ContentResolver to use. 
Experience pair programming with AI  Get Codota for Java