views:

96

answers:

2

Hello,

I'm trying to delete a bookmark using contentResolver.delete() and I get force close for missing permission "com.android.broswer.permission.WRITE_HISTORY_BOOKMARKS" but it's in the manifest...

this is in the manifest (outside <application></application>)

<uses-permission android:name="com.android.browser.permission.READ_HISTORY_BOOKMARKS"></uses-permission>
    <uses-permission android:name="com.android.broswer.permission.WRITE_HISTORY_BOOKMARKS"></uses-permission>

this is the method:

public void deleteBookmark(Cursor cur, long id) {
        getContentResolver().delete(BOOKMARKS_URI, "_id = " + id, null);
    }

(ignore the unused Cursor)

and this is the logcat:

E/AndroidRuntime(26750): FATAL EXCEPTION: main
E/AndroidRuntime(26750): java.lang.SecurityException: Permission Denial: writing
 com.android.browser.BrowserProvider uri content://browser/bookmarks from pid=26
750, uid=10001 requires com.android.browser.permission.WRITE_HISTORY_BOOKMARKS
E/AndroidRuntime(26750):        at android.os.Parcel.readException(Parcel.java:1
260)
E/AndroidRuntime(26750):        at android.database.DatabaseUtils.readExceptionF
romParcel(DatabaseUtils.java:160)
E/AndroidRuntime(26750):        at android.database.DatabaseUtils.readExceptionF
romParcel(DatabaseUtils.java:114)
E/AndroidRuntime(26750):        at android.content.ContentProviderProxy.delete(C
ontentProviderNative.java:472)
E/AndroidRuntime(26750):        at android.content.ContentResolver.delete(Conten
tResolver.java:675)
E/AndroidRuntime(26750):        at com.droidil.droidmarks.Dmarks.deleteBookmark(
Dmarks.java:167)
E/AndroidRuntime(26750):        at com.droidil.droidmarks.Dmarks.onContextItemSe
lected(Dmarks.java:138)
E/AndroidRuntime(26750):        at android.app.Activity.onMenuItemSelected(Activ
ity.java:2199)
E/AndroidRuntime(26750):        at com.android.internal.policy.impl.PhoneWindow$
ContextMenuCallback.onMenuItemSelected(PhoneWindow.java:2744)
E/AndroidRuntime(26750):        at com.android.internal.view.menu.MenuItemImpl.i
nvoke(MenuItemImpl.java:143)
E/AndroidRuntime(26750):        at com.android.internal.view.menu.MenuBuilder.pe
rformItemAction(MenuBuilder.java:855)
E/AndroidRuntime(26750):        at com.android.internal.view.menu.MenuDialogHelp
er.onClick(MenuDialogHelper.java:137)
E/AndroidRuntime(26750):        at com.android.internal.app.AlertController$Aler
tParams$3.onItemClick(AlertController.java:875)
E/AndroidRuntime(26750):        at android.widget.AdapterView.performItemClick(A
dapterView.java:284)
E/AndroidRuntime(26750):        at android.widget.ListView.performItemClick(List
View.java:3382)
E/AndroidRuntime(26750):        at android.widget.AbsListView$PerformClick.run(A
bsListView.java:1696)
E/AndroidRuntime(26750):        at android.os.Handler.handleCallback(Handler.jav
a:587)
E/AndroidRuntime(26750):        at android.os.Handler.dispatchMessage(Handler.ja
va:92)
E/AndroidRuntime(26750):        at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime(26750):        at android.app.ActivityThread.main(ActivityThrea
d.java:4627)
E/AndroidRuntime(26750):        at java.lang.reflect.Method.invokeNative(Native
Method)
E/AndroidRuntime(26750):        at java.lang.reflect.Method.invoke(Method.java:5
21)
E/AndroidRuntime(26750):        at com.android.internal.os.ZygoteInit$MethodAndA
rgsCaller.run(ZygoteInit.java:868)
E/AndroidRuntime(26750):        at com.android.internal.os.ZygoteInit.main(Zygot
eInit.java:626)
E/AndroidRuntime(26750):        at dalvik.system.NativeStart.main(Native Method)

Any idea why it says Permission Denial when it's clearly in the manifest? Maybe my code is the problem?

+1  A: 

Did you check this post

http://groups.google.com/group/android-developers/browse_thread/thread/6f994ddc2f010708

It says the following

Anything in the com.android.* package is a private API and you should not rely on it as it could break in a future update.

Things that are public are (usually) android.* (minus the leading com.) and are described in the SDK documentation.

Rahul
Yeah but this is true for OS versions other than Froyo and I'm working on Froyo 2.2 SDK 8... the READ permission works... so it's weird the WRITE one isn't. :\
liorry
Also, my add bookmark function works great... and I guess it uses the WRITE permission.
liorry
It might be that Android might have blocked write permissions to bookmark for 3rd party apps since any application should not be able to delete your bookmarks stored on a browser..some security constraint. However reading or even adding a new bookmark will not do much harm there...
Rahul
But there are applications in the Market which allows editing and deleting browser bookmarks... any chance my code causes this?
liorry
Yes you are correct this issue has been fixed in 2.2 as per bug tracker. I assume that you are also compiling your code in 2.2 http://code.google.com/p/android/issues/detail?id=7232
Rahul
Yes I'm compiling in android 2.2 sdk 8... that's why i'm surprised it's not working :\
liorry
So no one have a solution? :-(
liorry
+1  A: 

OMG! sorry for this, my mistake!

it should be BROWSER :0)

a typo wasted my whole weekend...

BTW: is supported only in Android 2.2.

liorry