One of the Divine Attributes Allah, The Most Exalted, Has is Infinite Knowledge that encompasses everything in the heavens and earth and what is in between them; in the worldly life and the Hereafter. Therefore, among His Divine Names is the All-Knowing. He, the Almighty says (what means): “Verily, He, only He, is the All-Hearer, the All-Knower.” [Qur’an 26: 220]
Allah Almighty has called Himself by some other Names which reflect this attribute, such as Al-Khabeer (the All-Aware), which entails that He knows what will be before it happens; Al-Hakeem (the Wise), which entails that He knows the details of things; Ash-Shaheed (the Witness), which entails that He knows what is unseen and what is seen, i.e., that nothing is unknown to Him; and Al-Muhsiy (the Reckoner), which entails that the fact that He knows so much does not distract Him from knowing the tiniest details, such as the light of the day and how strong the wind is, and when the leaves fall. He knows the numbers and the movements of each leaf.

His Knowledge encompasses generalities and minor details:
Some philosophers claim that Allah knows things in general terms, but He does not know minor details. This, no doubt, is a sheer lie. The
Knowledge of Allah, Glory is to Him, is comprehensive and all-encompassing, and nothing whatsoever is hidden from Him on earth or in the heavens. He knows every movement on land and in the depths of the sea, and there is no leaf that falls from a tree or a seed that is planted in the ground, or a small plant that cleaves the earth, or dries out or dies, but the Knowledge of Allah encompasses it. Allah Almighty says (what means): “...And He knows whatever there is in the land and in the sea; not a leaf falls, but He knows it. There is not a grain in the darkness of the earth, nor anything fresh or dry, but is written in a Clear Record.” [Qur’an 6: 59]
Nothing of the innumerable animals, birds, insects, etc. is hidden from Allah, as stated in the verse (which means): “And no moving [living] creature is there on earth but its provision is due from Allah. And He knows its dwelling place and its deposit [in the uterus or grave]. All is in a Clear Book [the Preserved Tablet].” [Qur’an 11: 6]
There is nothing that goes down into the earth, or ascends from the earth to the heavens, but Allah encompasses it with His Infinite Knowledge. Allah says (what means):
“He knows that which goes into the earth and that which comes forth from it, and that which descends from the heaven and that which ascends to it. And He is the Most Merciful, the Oft-Forgiving.” [Qur’an 34: 2]
Nothing of man is hidden from Allah, the All-Knowing, whatsoever. Allah’s Knowledge of man is comprehensive, encompassing his apparent and visible actions, but He also knows what is hidden in the depths of his soul, as stated in the verse (which means): “Say [O Muhammad]: ‘Whether you hide what is in your breasts or reveal it, Allah knows it...’” [Qur’an 3: 29]
And the verse (which means): “And He is Allah [to be worshipped Alone] in the heavens and on the earth; He Knows what you conceal and what you reveal...” [Qur’an 6: 3]
All the disasters and tribulations that happen on earth, or happen to the individual, or to his wealth or family, etc., were known to Allah before they happened, He has written them in the Preserved Tablet as He says (what means):  “No disaster strikes upon the earth or among yourselves except that it is in a register before We bring it into being — indeed that, for Allah, is easy.” [Qur’an 57:22]  
Allah’s Knowledge encompasses all the minor details of man’s life. He, the All-Knowing says (what means): “Neither you [O Muhammad] do any deed nor recite any portion of the Qur’an, nor you [O mankind] do any deed [good or evil], but We are Witness thereof, when you are doing it...” [Qur’an 10: 61]
In the Noble Qur’an, Almighty Allah reports the invaluable advice which Luqmaan (a wise pious man) gave to his son in regards to pure faith in Allah, the Most Exalted. This is in the verse (which means):
“O my son! If it be [anything] equal to the weight of a grain of mustard seed, and though it be in a rock, or in the heavens or in the earth, Allah will bring it forth. Verily, Allah is Subtle [in bringing out that grain], Well-Aware [of its place].” [Qur’an 3l: 16]
For the Knowledge of Allah, secret and open, small and great, unseen and seen, are all the same, as in the verse (which means):
“Allah knows what every female carries and what the wombs lose [prematurely] or exceed. And everything with Him is by due measure.
[He is] (He is the) Knower of the unseen and the seen, the Grand, the Exalted. It is the same [to Him] concerning you whether one conceals [his] speech or one publicises it and whether one is hidden by night or conspicuous [among others] by day.” [Qur’an 13: 8-10]
Allah, the Almighty, indeed spoke the truth when He said (what means):
“... And nothing is hidden from your Lord [so much as] the weight of an atom [or small ant] on the earth or in the heaven. Not what is less than that or what is greater than that but is [written] in a Clear Record.” [Qur’an 10: 61]
Allah’s Knowledge: An excuse not to exert effort?

Some might raise a question like: “If Allah Knows or Decrees certain catastrophes or trials to happen, then why should I strive to avoid them?” Or, “If Allah destined that a given person will live as a disbeliever and later is to be doomed to Hell, why should He punish him?”
The answer to such a misconception is that Allah, the Most Exalted, has endowed man with ability, will and volition, and He has shown him the two ways: that of good and that of evil through His revelations to His Messengers may Allah exalt their mention. So, whoever chooses the way of good, Allah will guide him and grant him success and the opposite is true. Allah says (what means): “And (We, i.e. Allah) have shown him the two ways - of good and evil”. [Qur’an 90:10].
Allah also says (what means): “Whosoever desires (through his deeds) the reward of the Hereafter, We give him increase in his reward, and whosoever desires the reward of this world (through his deeds), We give him thereof (what is written for him), and he has no portion in the Hereafter.” [Qur’an 42:20].
The abovementioned verses clarify that one has the volition and not obliged to do things against his will. For example, no one can deny that man has a volition concerning material affairs such as livelihood: he spares no effort to gain more and more although he knows that his livelihood is predestined.
Another example is that concerning one’s seeking each and every remedy and means of safety to avoid harm.
Article source: http://www.islamweb.net/emainpage/