Question: When executing:

```
path=os.path.dirname(__file__)+'/log.txt'
log=open(path,"w",encoding='utf-8')

```

I get:

```
log=open(path,'w',encoding='utf-8')
File "C:\Program Files\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 1203, in __init__
raise IOError('invalid mode: %s' % mode)
IOError: invalid mode: w

```

I'm not sure why I can't write to the file?

Answer: 
I think you need to have your own model classes from wherein you can set and get your song title. For this and other information, see Stack Overflow question:  

[How to set the PlayList Index for Mediaplayer(ExpressionMediaPlayer:Mediaplayer)](https://stackoverflow.com/questions/2780295/how-to-set-the-playlist-index-for-mediaplayerexpressionmediaplayermediaplayer).

If you are keen to know how it is being implemented, you can get the [source](https://android.googlesource.com/platform/packages/apps/Music/+/master) and see how they have implemented.
I learned how to do it just now, so I don't know if it works on all versions of android yet. 

```
private void getTrackInfo(Uri audioFileUri) {
    MediaMetadataRetriever metaRetriever= new MediaMetadataRetriever();
    metaRetriever.setDataSource(getRealPathFromURI(audioFileUri));
    String artist = metaRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ARTIST);
    String title = metaRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_TITLE);

}

private String getRealPathFromURI(Uri uri) {
    File myFile = new File(uri.getPath().toString());
    String s = myFile.getAbsolutePath();
    return s;
}

```