diff options
author | Jindong <jindong.yue@nxp.com> | 2019-11-20 15:57:23 +0800 |
---|---|---|
committer | Jindong <jindong.yue@nxp.com> | 2019-12-09 14:06:26 +0800 |
commit | 339c1f2461acfff7cf239858c428d395c1e7b35e (patch) | |
tree | ef10ddf8c5ce59d362647df644568f9bd454e8d3 | |
parent | f1cfef4ea098d3665423ce8f369fa2a13860859f (diff) | |
download | SoundRecorder-339c1f2461acfff7cf239858c428d395c1e7b35e.tar.gz |
app crash due to Invalid column count IllegalArgumentException
Click "Done" button after recording, will meet below exception:
--------- beginning of crash
E AndroidRuntime: FATAL EXCEPTION: main
E AndroidRuntime: Process: com.android.soundrecorder, PID: 21475
E AndroidRuntime: java.lang.IllegalArgumentException: Invalid column count(*)
E AndroidRuntime: at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:170)
E AndroidRuntime: at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:140)
E AndroidRuntime: at android.content.ContentProviderProxy.query(ContentProviderNative.java:423)
E AndroidRuntime: at android.content.ContentResolver.query(ContentResolver.java:944)
E AndroidRuntime: at android.content.ContentResolver.query(ContentResolver.java:880)
E AndroidRuntime: at android.content.ContentResolver.query(ContentResolver.java:836)
E AndroidRuntime: at com.android.soundrecorder.SoundRecorder.addToPlaylist(SoundRecorder.java:552)
E AndroidRuntime: at com.android.soundrecorder.SoundRecorder.addToMediaDB(SoundRecorder.java:649)
E AndroidRuntime: at com.android.soundrecorder.SoundRecorder.saveSample(SoundRecorder.java:479)
E AndroidRuntime: at com.android.soundrecorder.SoundRecorder.onClick(SoundRecorder.java:420)
Change-Id: I5c77741f49a9b9f37d0c4e6512a9adb5b755f1b7
Signed-off-by: Jindong <jindong.yue@nxp.com>
-rw-r--r-- | src/com/android/soundrecorder/SoundRecorder.java | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/src/com/android/soundrecorder/SoundRecorder.java b/src/com/android/soundrecorder/SoundRecorder.java index 3970188..2067d6a 100644 --- a/src/com/android/soundrecorder/SoundRecorder.java +++ b/src/com/android/soundrecorder/SoundRecorder.java @@ -533,18 +533,22 @@ public class SoundRecorder extends Activity * play_order in the playlist. */ private void addToPlaylist(ContentResolver resolver, int audioId, long playlistId) { - String[] cols = new String[] { + try { + String[] cols = new String[] { "count(*)" - }; - Uri uri = MediaStore.Audio.Playlists.Members.getContentUri("external", playlistId); - Cursor cur = resolver.query(uri, cols, null, null, null); - cur.moveToFirst(); - final int base = cur.getInt(0); - cur.close(); - ContentValues values = new ContentValues(); - values.put(MediaStore.Audio.Playlists.Members.PLAY_ORDER, Integer.valueOf(base + audioId)); - values.put(MediaStore.Audio.Playlists.Members.AUDIO_ID, audioId); - resolver.insert(uri, values); + }; + Uri uri = MediaStore.Audio.Playlists.Members.getContentUri("external", playlistId); + Cursor cur = resolver.query(uri, cols, null, null, null); + cur.moveToFirst(); + final int base = cur.getInt(0); + cur.close(); + ContentValues values = new ContentValues(); + values.put(MediaStore.Audio.Playlists.Members.PLAY_ORDER, Integer.valueOf(base + audioId)); + values.put(MediaStore.Audio.Playlists.Members.AUDIO_ID, audioId); + resolver.insert(uri, values); + } catch (IllegalArgumentException ex) { + Log.e(TAG, "Catch IllegalArgumentException: Invalid column count(*)"); + } } /* |