The nature of recharging magic items is something that is partially left to the DM to decide for the campaign world. The following system is offered, extrapolated from what the rulebooks give us about magic item manufacture.
Rechargeable magic items typically must have a certain spell cast on them before they can be recharged. The spell must be cast immediately prior to casting any number of spells “into” the device to recharge it. After a turn passes without any spells being added, the requisite priming spell must be cast again.
Magic-users must first cast enchant an item, illusionists must cast major creation, clerics must cast commune, and druids must cast commune with nature. Certain items’ descriptions state they may be recharged by a caster of a lower level than is required for one of these spells; these are exceptions and in such a case the device may be recharged by simply casting a spell into the item.
Once the device has been prepared, spells are simply cast normally, the magic flowing “into” the device. For the device to regain a single charge, every spell effect the device is capable of producing must be cast once.
For example, fear could be cast into a wand of fear to give it a charge, since that is the wand's only ability. But a wand of frost, capable of producing ice storm, wall of ice, and cone of cold, would need each of those spells cast once to recover a single charge. A staff of the magi requires a single casting of every charge-using spell effect – 14 spells for a single charge!
The caster who casts the preparatory spell does not need to be the one to recharge the device. However, in such a case, the character(s) actually recharging the device must be of the same class which has access to the preparatory spell used, even if they themselves cannot yet cast the preparatory spell. For example, a cleric cannot recharge a device prepared with an enchant an item spell, even if the device is usable by both clerics and magic-users.