Things You'll Need
Liquid fabric glue
Epoxy or spray adhesive
The type of glue you use to attach fabric to denim depends on the the kind of fabric you are working with and what you are trying to make. For instance, you could use one type of glue for a craft that you wouldn't be wearing and a different type of glue for a pair of jeans with a patch attached to them. Some kinds of glue will hold up in a washing machine, while others won't. You need to choose the right kind to make sure your project lasts.
Apply liquid fabric glue to the back of a fabric patch and press it down on a pair of jeans or any other denim item that you will wearing or putting through a washing and drying cycle. Fabric glue will make the fabric feel a little stiff, so brush on a thin, even layer if the fabric for the patch is thin, like silk or satin. Fabric glue is made for being put through a washing machine.
Use PVA glue, otherwise know as Elmer's Glue or craft glue, for a child's craft project because of its non-toxic nature. You can also use craft glue if the fabric you are gluing to the denim is not heavy or thick and you know you won't be putting the project through the washing process. Craft glue is water based and will soften if it gets wet, so it also isn't good for outdoor items.
Squeeze some epoxy like E6000 onto your fabric to attach to denim. Epoxy is ideal for projects that get stretched and banged around a lot because of its strength and elasticity--so it would be useful for gluing fabric embellishments to denim purses or jackets. It is also waterproof and will stand up to being put through washing and drying machines on the delicate cycle.
Apply a spray adhesive like 3M 77 or Elmer's spray adhesive to denim and smooth the fabric onto it. Spray adhesive is flexible and won't deteriorate in the washing or drying machine on the delicate cycle. This is ideal for embellishing cushions with denim.