The 49ers will host the Houston Texas in their first preseason game, and the Raiders will open against the Cardinals in Arizona.
The preseason openers will be played between Aug. 11 and Aug. 15.
The 49ers visit Denver in week two (Aug. 18-22), then host Green Bay (Aug. 25-28) and wrap up the preseason at San Diego on Sept. 1.
The Raiders also play at Green Bay (Aug. 18-22) before hosting Tennessee (Aug. 27) and Seattle (Sept. 1).
The NFL is expected to announce the regular season schedule later this month.