Code example for Uri

Methods: getPathSegments, parseId

0
 
            if (packageName == null || className == null) {
                return false; 
            } 
             
            ComponentName cn = new ComponentName(packageName, className);
             
            boolean allocatedAppWidgets = false;
            final AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(mContext);
 
            try { 
                int appWidgetId = mAppWidgetHost.allocateAppWidgetId();
                 
                values.put(Favorites.ITEM_TYPE, Favorites.ITEM_TYPE_APPWIDGET);
                values.put(Favorites.SPANX, a.getString(R.styleable.Favorite_spanX));
                values.put(Favorites.SPANY, a.getString(R.styleable.Favorite_spanY));
                values.put(Favorites.APPWIDGET_ID, appWidgetId);
                db.insert(TABLE_FAVORITES, null, values);
 
                allocatedAppWidgets = true;