Hi guys, just want to ask about SQLite and MediaPlayer

Put your problem here if it does not fit any of the other categories.

Hi guys, just want to ask about SQLite and MediaPlayer

Postby xiiinookie » Mon Apr 23, 2012 9:11 am

I have my sqlite that saves "paths" of audio files from SD Card. Since SD Card had problem on special char, I used escape character (e.i. of my path = /sdcard/Music/A poem of bragi.mp3 which I convert to '/sdcard/Music/A poem of bragi.mp3' so that the sqlite accept it.) Now after saving, I'm gonna call it to another activity to play it. here's my code:

Cursor cAlarm = AlarmDB.rawQuery("SELECT * FROM " + CrazyAlarmMain.TABLE_ALARM + " WHERE _id = 1;", null);
if (cAlarm != null ) {
if(cAlarm.moveToFirst()) {
strName = cAlarm.getString(cAlarm.getColumnIndex("alarm_name"));

strRep = cAlarm.getString(cAlarm.getColumnIndex("alarm_custom"));
Log.v("count", strRep);
try {
mp.reset();
mp.setDataSource(String.valueOf(strRep));
mp.prepare();
mp.start();
} catch (IOException e) {
Log.v("count", "failed");
}

Since the strRep (which has been escaped char, produce a value of /sdcard/Music/A poem of bragi.mp3 which is ready to be played, it causes me some nullpointers which is so confusing..)

I hope you could help me about this guys... TIA.. :D
xiiinookie
Once Poster
Once Poster
 
Posts: 1
Joined: Mon Apr 23, 2012 9:02 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Google [Bot] and 21 guests