Call this function you have to pass two parameter ListName and query.
ListName : This is name of list in which you want to create view.Query : You have to pass CAML Query base on which filter is set and your view is created. Like