Suppose a person living in the United States wants to learn about India. He has two options: he could visit India and learn about the people and places there or he could just pick up a book about India and read it. The first option will be expensive and time consuming, but at the same time it gives one first hand information and a sense of satisfaction while the second option is less expensive and saves time.
A person can gain knowledge and learn many valuable lessons through his/her own practical experiences and also the experiences of others. The knowledge learnt from experience is very likely to be retained in our memory for a long period of time. The conclusions that we draw from what we learn would be from our practical experience instead of accepting the conclusion drawn in the book by the author.
So in my opinion knowledge can be gained both by reading books and by experience but the knowledge gained through experience is more important.