David would have had a book of the Law: Genesis through Deuteronomy and possibly some other writings such as Joshua, Judges, Ruth.
Joshua 1:8 This book of the law shall not depart out of thy mouth; but thou shalt meditate therein day and night, that thou mayest observe to do according to all that is written therein: for then thou shalt make thy way prosperous, and then thou shalt have good success.
Joshua had access to the "book of the law", the Torah, which is the first five books of the Bible.
To see these passages in a larger format, please set your computer display to view much larger print. I have no control over the way your computer displays text but you do have that control.
I hope you have found this helpful.