2016-07-06 74 views

回答

0

我假设你的数据库中有三列 -
1. id作为id
2.歌曲名称为song_name
3.路径歌曲作为path

第1步:查询数据库来获取的路径歌曲要播放

Cursor c = yourDBHelper.query(TABLE_NAME, new String[] {"path"}, 
       new String[] {"song_name=?"}, new String[] {"<song_name>"}, 
              null, null, null); 
if(c.moveToFirst()) path = c.getString(0); // This should give the path if the 
               query was executed with no errors 

第2步:初始化的MediaPlayer与上述路径

MediaPlayer mediaPlayer = MediaPlayer.create(context, path); 

第3步:享受音乐

mediaPlayer.start(); 

对于databsase相关的帮助 - https://developer.android.com/training/basics/data-storage/databases.html
对于MediaPlayer的帮助 - https://developer.android.com/guide/topics/media/mediaplayer.html

此外,力明白你的意思在这里 -

如何阅读那首歌来自那个链接