The time and circumstances in which the psalm was composed are not certain. Some suggest that the psalm was written in the time David spent in Hebron, but this is inconclusive.
The psalm alternately speaks to God (Psalm 16:1, 5-6, 10-11) and about God (Psalm 16:2-4, 7-9).
1 Preserve me, O God, for in you I take refuge.