Closed BryceStevenWilley closed 8 years ago
Yeah... I think there was some problem with the sql statement!
So before, the delete song method in the helper does not delete the songs properly:
01-21 23:06:49.552 14452-14452/com.example.karenlee.app I/SETUP_ACTIVITY: songs in local machine - [1442 BAE BAE by 빅뱅, 0.0 bpm, 1444 Bang Bang Bang by 빅뱅, 0.0 bpm, 1451 Celebrate by Mika Feat. Pharrell Williams, 0.0 bpm, 1449 Clocks by Coldplay, 0.0 bpm, 1437 DADDY by PSY, 0.0 bpm, 1447 I by 태연, 0.0 bpm, 1439 I'm Fine by 김동완, 0.0 bpm, 1446 Wow Wow Wow by 전진, 0.0 bpm, 1454 サマーラブ by 青山テルマ, 0.0 bpm, 1438 나팔바지 by PSY, 0.0 bpm, 1448 맙소사 by 황태지, 0.0 bpm, 1450 사랑이 뭐길래 by Lee Juck (이적), 0.0 bpm, 1436 스물셋 by IU(아이유), 0.0 bpm, 1440 음오아예 by 마마무, 0.0 bpm, 1441 음오아예 by 마마무, 0.0 bpm] 01-21 23:06:49.557 14452-14452/com.example.karenlee.app I/SETUP_ACTIVITY: songs in database - [1435 4 Walls by f(x), 196.0 bpm, 1442 BAE BAE by 빅뱅, 411.0 bpm, 1443 Bang Bang Bang by 빅뱅, 298.0 bpm, 1444 Bang Bang Bang by 빅뱅, 391.0 bpm, 1451 Celebrate by Mika Feat. Pharrell Williams, 499.0 bpm, 1449 Clocks by Coldplay, 481.0 bpm, 1437 DADDY by PSY, 416.0 bpm, 1447 I by 태연, 304.0 bpm, 1439 I'm Fine by 김동완, 541.0 bpm, 1452 I'm Not The Only One by Sam Smith, 512.0 bpm, 1453 Stay With Me by Sam Smith, 273.0 bpm, 1446 Wow Wow Wow by 전진, 407.0 bpm, 1454 サマーラブ by 青山テルマ, 162.0 bpm, 1438 나팔바지 by PSY, 218.0 bpm, 1448 맙소사 by 황태지, 190.0 bpm, 1450 사랑이 뭐길래 by Lee Juck (이적), 339.0 bpm, 1436 스물셋 by IU(아이유), 33.0 bpm, 1445 오늘부터 우리는(Me gustas tu) by 여자친구, 87.0 bpm, 1440 음오아예 by 마마무, 554.0 bpm, 1441 음오아예 by 마마무, 122.0 bpm] 01-21 23:06:49.557 14452-14452/com.example.karenlee.app I/SETUP_ACTIVITY: songs that should be added - [] 01-21 23:06:49.562 14452-14452/com.example.karenlee.app I/SETUP_ACTIVITY: songs that should be deleted - [1435 4 Walls by f(x), 196.0 bpm, 1452 I'm Not The Only One by Sam Smith, 512.0 bpm, 1453 Stay With Me by Sam Smith, 273.0 bpm, 1445 오늘부터 우리는(Me gustas tu) by 여자친구, 87.0 bpm] 01-21 23:06:49.572 14452-14452/com.example.karenlee.app I/SETUP_ACTIVITY: songs in database after deleting - [1435 4 Walls by f(x), 196.0 bpm, 1442 BAE BAE by 빅뱅, 411.0 bpm, 1443 Bang Bang Bang by 빅뱅, 298.0 bpm, 1444 Bang Bang Bang by 빅뱅, 391.0 bpm, 1451 Celebrate by Mika Feat. Pharrell Williams, 499.0 bpm, 1449 Clocks by Coldplay, 481.0 bpm, 1437 DADDY by PSY, 416.0 bpm, 1447 I by 태연, 304.0 bpm, 1439 I'm Fine by 김동완, 541.0 bpm, 1452 I'm Not The Only One by Sam Smith, 512.0 bpm, 1453 Stay With Me by Sam Smith, 273.0 bpm, 1446 Wow Wow Wow by 전진, 407.0 bpm, 1454 サマーラブ by 青山テルマ, 162.0 bpm, 1438 나팔바지 by PSY, 218.0 bpm, 1448 맙소사 by 황태지, 190.0 bpm, 1450 사랑이 뭐길래 by Lee Juck (이적), 339.0 bpm, 1436 스물셋 by IU(아이유), 33.0 bpm, 1445 오늘부터 우리는(Me gustas tu) by 여자친구, 87.0 bpm, 1440 음오아예 by 마마무, 554.0 bpm, 1441 음오아예 by 마마무, 122.0 bpm] 01-21 23:06:49.572 14452-14452/com.example.karenlee.app I/SETUP_ACTIVITY: Added songs are [], isSetup is false 01-21 23:06:49.572 14452-14452/com.example.karenlee.app I/SETUP_ACTIVITY: Songs already in DB; finishing the activity
and now, it does:
01-21 23:48:21.977 22872-22872/com.example.karenlee.app I/SETUP_ACTIVITY: songs in local machine - [1442 BAE BAE by 빅뱅, 0.0 bpm, 1444 Bang Bang Bang by 빅뱅, 0.0 bpm, 1451 Celebrate by Mika Feat. Pharrell Williams, 0.0 bpm, 1449 Clocks by Coldplay, 0.0 bpm, 1437 DADDY by PSY, 0.0 bpm, 1447 I by 태연, 0.0 bpm, 1439 I'm Fine by 김동완, 0.0 bpm, 1446 Wow Wow Wow by 전진, 0.0 bpm, 1454 サマーラブ by 青山テルマ, 0.0 bpm, 1438 나팔바지 by PSY, 0.0 bpm, 1448 맙소사 by 황태지, 0.0 bpm, 1450 사랑이 뭐길래 by Lee Juck (이적), 0.0 bpm, 1436 스물셋 by IU(아이유), 0.0 bpm, 1440 음오아예 by 마마무, 0.0 bpm, 1441 음오아예 by 마마무, 0.0 bpm] 01-21 23:48:21.982 22872-22872/com.example.karenlee.app I/SETUP_ACTIVITY: songs in database - [1435 4 Walls by f(x), 196.0 bpm, 1442 BAE BAE by 빅뱅, 411.0 bpm, 1443 Bang Bang Bang by 빅뱅, 298.0 bpm, 1444 Bang Bang Bang by 빅뱅, 391.0 bpm, 1451 Celebrate by Mika Feat. Pharrell Williams, 499.0 bpm, 1449 Clocks by Coldplay, 481.0 bpm, 1437 DADDY by PSY, 416.0 bpm, 1447 I by 태연, 304.0 bpm, 1439 I'm Fine by 김동완, 541.0 bpm, 1452 I'm Not The Only One by Sam Smith, 512.0 bpm, 1453 Stay With Me by Sam Smith, 273.0 bpm, 1446 Wow Wow Wow by 전진, 407.0 bpm, 1454 サマーラブ by 青山テルマ, 162.0 bpm, 1438 나팔바지 by PSY, 218.0 bpm, 1448 맙소사 by 황태지, 190.0 bpm, 1450 사랑이 뭐길래 by Lee Juck (이적), 339.0 bpm, 1436 스물셋 by IU(아이유), 33.0 bpm, 1445 오늘부터 우리는(Me gustas tu) by 여자친구, 87.0 bpm, 1440 음오아예 by 마마무, 554.0 bpm, 1441 음오아예 by 마마무, 122.0 bpm] 01-21 23:48:21.982 22872-22872/com.example.karenlee.app I/SETUP_ACTIVITY: songs that should be added - [] 01-21 23:48:21.987 22872-22872/com.example.karenlee.app I/SETUP_ACTIVITY: songs that should be deleted - [1435 4 Walls by f(x), 196.0 bpm, 1452 I'm Not The Only One by Sam Smith, 512.0 bpm, 1453 Stay With Me by Sam Smith, 273.0 bpm, 1445 오늘부터 우리는(Me gustas tu) by 여자친구, 87.0 bpm] 01-21 23:48:22.002 22872-22872/com.example.karenlee.app I/SETUP_ACTIVITY: songs in database after deleting - [1442 BAE BAE by 빅뱅, 411.0 bpm, 1443 Bang Bang Bang by 빅뱅, 298.0 bpm, 1444 Bang Bang Bang by 빅뱅, 391.0 bpm, 1451 Celebrate by Mika Feat. Pharrell Williams, 499.0 bpm, 1449 Clocks by Coldplay, 481.0 bpm, 1437 DADDY by PSY, 416.0 bpm, 1447 I by 태연, 304.0 bpm, 1439 I'm Fine by 김동완, 541.0 bpm, 1446 Wow Wow Wow by 전진, 407.0 bpm, 1454 サマーラブ by 青山テルマ, 162.0 bpm, 1438 나팔바지 by PSY, 218.0 bpm, 1448 맙소사 by 황태지, 190.0 bpm, 1450 사랑이 뭐길래 by Lee Juck (이적), 339.0 bpm, 1436 스물셋 by IU(아이유), 33.0 bpm, 1440 음오아예 by 마마무, 554.0 bpm, 1441 음오아예 by 마마무, 122.0 bpm] 01-21 23:48:22.002 22872-22872/com.example.karenlee.app I/SETUP_ACTIVITY: Added songs are [], isSetup is false 01-21 23:48:22.002 22872-22872/com.example.karenlee.app I/SETUP_ACTIVITY: Songs already in DB; finishing the activity
I don't really see why the sql statement did not work... though. So before the fix, it was:
String selection = "? EQUALS ? AND ? EQUALS ?"; String[] selectionArgs = {SongBPMEntry.COLUMN_NAME_ARTIST, song.getArtist(), SongBPMEntry.COLUMN_NAME_TITLE, song.getTitle()};
and I have tried:
1
String selection = "? EQUALS ? AND ? EQUALS ?"; String[] selectionArgs = {SongBPMEntry.COLUMN_NAME_ARTIST, "\'" + song.getArtist() + "\'", SongBPMEntry.COLUMN_NAME_TITLE, "\'" + song.getTitle() + "\'"};
since artists and titles are in string, but it did not work.
I also have tried:
2
String selection = "?=? AND ?=?"; String[] selectionArgs = {SongBPMEntry.COLUMN_NAME_ARTIST, "\'" + song.getArtist() + "\'", SongBPMEntry.COLUMN_NAME_TITLE, "\'" + song.getTitle() + "\'"};
this one didn't work too.
now, I am comparing the song id's to delete it.
String selection = SongBPMEntry.COLUMN_NAME_SONG_ID + "=?"; String[] selectionArgs = {Long.toString(song.getID())};
and it seems to work. :)
2016-01-21 19:25 GMT-06:00 Bryce Willey notifications@github.com:
Assigned #4 https://github.com/jemitk/Pacer/issues/4 to @jemitk https://github.com/jemitk.
— Reply to this email directly or view it on GitHub https://github.com/jemitk/Pacer/issues/4#event-522435429.
I'm closing the issue! :)
Confirmed fixed.
Here's the stack trace. Looks like it has something to do with the bpm data base, specifically one of the delete queries that is happening.
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.karenlee.app/com.example.karenlee.app.SetupActivity}: android.database.sqlite.SQLiteException: near "EQUALS": syntax error (code 1): , while compiling: DELETE FROM bpmmapping WHERE ? EQUALS ? AND ? EQUALS ? at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2339) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2413) at android.app.ActivityThread.access$800(ActivityThread.java:155) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1317) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5343) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700) Caused by: android.database.sqlite.SQLiteException: near "EQUALS": syntax error (code 1): , while compiling: DELETE FROM bpmmapping WHERE ? EQUALS ? AND ? EQUALS ? at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method) at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:889) at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:500) at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588) at android.database.sqlite.SQLiteProgram.(SQLiteProgram.java:58)
at android.database.sqlite.SQLiteStatement.(SQLiteStatement.java:31)
at android.database.sqlite.SQLiteDatabase.delete(SQLiteDatabase.java:1496)
at com.example.karenlee.app.db.SongBPMDbHelper.deleteSong(SongBPMDbHelper.java:140)
at com.example.karenlee.app.db.SongBPMDbHelper.deleteSongs(SongBPMDbHelper.java:148)
at com.example.karenlee.app.SetupActivity.compareToDb(SetupActivity.java:259)
at com.example.karenlee.app.SetupActivity.onCreate(SetupActivity.java:59)
at android.app.Activity.performCreate(Activity.java:6010)