hi,
the favicon field returned by the browser bookmark provider is a
sqlite blob.
I want to display the bookmarks in a listview with the favicon but
couldn't find a way to do it.
I tried using a SimpleCursorAdapter.ViewBinder but I get an exception.

this is what my code looks like :


                Cursor bookmarks;
                String[] proj = new String[] {
                        android.provider.Browser.BookmarkColumns.URL,
                        android.provider.Browser.BookmarkColumns.TITLE,
                        android.provider.Browser.BookmarkColumns.FAVICON
                };
                bookmarks = managedQuery(android.provider.Browser.BOOKMARKS_URI,
proj, null, null, android.provider.Browser.BookmarkColumns.URL  + "
ASC");

                SimpleCursorAdapter adapter = new SimpleCursorAdapter(
                                this,
                                R.layout.bookmark_element,
                                bookmarks,
                                new String[] 
{android.provider.Browser.BookmarkColumns.URL,
android.provider.Browser.BookmarkColumns.TITLE,
android.provider.Browser.BookmarkColumns.FAVICON},
                                new int[] { R.id.url,R.id.titre, R.id.icon});
                adapter.setViewBinder(new BookmarkDataViewBinder());
                setListAdapter(adapter);


and this is my viewbinder class :

class BookmarkDataViewBinder implements SimpleCursorAdapter.ViewBinder
{
        @Override
        public boolean setViewValue(View view, Cursor cursor, int
columnIndex) {
                
if(view.getClass().getName().equals("android.widget.ImageView")) {
                        byte[] b = cursor.getBlob(columnIndex);
                        if(b != null) {
                                Bitmap bitmap = 
BitmapFactory.decodeByteArray(b, 0, b.length);
                                ((ImageView)view).setImageBitmap(bitmap);
                        }
                        else {
                                
((ImageView)view).setImageResource(R.drawable.icon);
                        }
                        return true;
                }
                return false;
        }
}


if the favicon blob field is null, the viewbinder does its job and it
displays the default icon. but if it is not null, this is the
exception I get :

E/AndroidRuntime( 1365): Uncaught handler: thread main exiting due to
uncaught exception
E/AndroidRuntime( 1365): android.database.sqlite.SQLiteException:
unknown error: Unable to convert BLOB to string
E/AndroidRuntime( 1365):        at
android.database.CursorWindow.getString_native(Native Method)
E/AndroidRuntime( 1365):        at
android.database.CursorWindow.getString(CursorWindow.java:278)
E/AndroidRuntime( 1365):        at
android.database.AbstractWindowedCursor.getString
(AbstractWindowedCursor.java:49)
E/AndroidRuntime( 1365):        at
android.database.CursorWrapper.getString(CursorWrapper.java:135)
E/AndroidRuntime( 1365):        at
android.widget.SimpleCursorAdapter.bindView(SimpleCursorAdapter.java:
119)
E/AndroidRuntime( 1365):        at android.widget.CursorAdapter.getView
(CursorAdapter.java:186)
E/AndroidRuntime( 1365):        at
android.widget.AbsListView.obtainView(AbsListView.java:1057)
E/AndroidRuntime( 1365):        at
android.widget.ListView.makeAndAddView(ListView.java:1622)
E/AndroidRuntime( 1365):        at android.widget.ListView.fillDown
(ListView.java:607)
E/AndroidRuntime( 1365):        at android.widget.ListView.fillGap
(ListView.java:578)
E/AndroidRuntime( 1365):        at
android.widget.AbsListView.trackMotionScroll(AbsListView.java:2232)
E/AndroidRuntime( 1365):        at android.widget.AbsListView
$FlingRunnable.run(AbsListView.java:2064)
E/AndroidRuntime( 1365):        at android.os.Handler.handleCallback
(Handler.java:542)
E/AndroidRuntime( 1365):        at android.os.Handler.dispatchMessage
(Handler.java:86)
E/AndroidRuntime( 1365):        at android.os.Looper.loop(Looper.java:
123)
E/AndroidRuntime( 1365):        at android.app.ActivityThread.main
(ActivityThread.java:3739)
E/AndroidRuntime( 1365):        at
java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 1365):        at java.lang.reflect.Method.invoke
(Method.java:515)
E/AndroidRuntime( 1365):        at com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:739)
E/AndroidRuntime( 1365):        at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:497)
E/AndroidRuntime( 1365):        at dalvik.system.NativeStart.main
(Native Method)


according to my logs, the exception occurs before my viewbinder is
called.

can somebody help?
thanks

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to