public void setRingtone(Context context, int resId) {
        if (resId > 0) {
            this.ringtoneUri = Uri.parse("android.resource://" +
                context.getPackageName() + "/" + resId);
        }
    }
public void setRingtone ( Context context , int resId ) { if ( resId > 0 ) { this . ringtoneUri = Uri . parse ( "android.resource://" + context . getPackageName ( ) + "/" + resId ) ; } }
Set ringtone resource.

@param context
@param resId