Maybe we could consider to use  ```AT+CGDCONT=?``` [1] to get the total number of data contexts.

[1] There are some example format in http://m2msupport.net/m2msupport/atcgdcont-define-pdp-context/