I am trying to delete some channels inserted by my app in TV.db via a JobService asynctaks.
Each time i am getting security exception while deleting.
Process: com.app, PID: 7026
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:304)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.SecurityException: Selection not allowed for content://android.media.tv/channel?input=<My package>%2F.live.TvInputService&browsable_only=false
at android.os.Parcel.readException(Parcel.java:1574)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:185)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:137)
at android.content.ContentProviderProxy.delete(ContentProviderNative.java:544)
at android.content.ContentResolver.delete(ContentResolver.java:1299)
at com.TvContractUtills.updateChannelsWithGraceNote(TvContractUtills.java:173)
at com.EpgUpdateTask.doInBackground(EpgUpdateTask.java:48)
at com.EpgUpdateTask.doInBackground(EpgUpdateTask.java:11)
at android.os.AsyncTask$2.call(AsyncTask.java:292)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
This line of code causing above error
resolver.delete(channelsUri,TvContract.Channels._ID+ " in ("+getListOfIds(availableChannelMap) +" )" , null);
availableChannelMap returns comma separated list of channel ids.
Same code works when i kept the where clause to null.
resolver.delete(channelsUri,null , null);
Any idea why this is happening.
To delete a channel, you need to call the
ContentResolver
like thisIf you want to delete multiple channels, put it in a loop. I am not sure if it's the correct way. I don't see any bulk delete method available in the
providers
API. It works though.