Every state has different rules for the establishment of residency.
In California, if you live in the state for at least 6 months and in the county for at least 3 months then you would be considered a resident of the state and could file in the county in which you live.
There are certain exceptions to this, such as those who are stationed here while in the military or navy etc. or those who are here on student visas. In these instances, a conversation with the attorney would determine if you could file in California.
It is important to note that if your spouse lives in California, you could also file here. However, if there are issues such as children or property and they exist in another state, then these issues would have to be addressed in that state– unless the parties agree and sign a Marital Settlement Agreement regarding these issues.
A consultation with the attorney will determine your legal rights and whether it is in your best interest to file in California.