WASHINGTON — Attorney General Eric H. Holder Jr. said Thursday that the federal government needed to improve how it tracks the number of times law enforcement officers across the country are shot at or fire their weapons, as part of an effort to restore trust between the police and the public.

To solve the problem, Mr. Holder said, local police departments and state agencies should be legally required to report all shooting incidents to the F.B.I. Such a measure would probably require a law passed by Congress.

“The first step to achieving this is to obtain better, more accurate data on the scope of the challenges we face,” Mr. Holder said, according to prepared remarks for a speech he was to give at a Justice Department ceremony in Washington honoring the Rev. Dr. Martin Luther King Jr. “Fixing this is an idea that we should all be able to unite behind.”

“For instance,” he added, “I’ve heard from a number of people who have called on policy makers to ensure better record-keeping on injuries and deaths that occur at the hands of police. I’ve also spoken with law enforcement leaders — including the leadership of the Fraternal Order of Police — who have urged elected officials to consider strategies for collecting better data on officer fatalities.