BlackBerry today reported better-than-expected adjusted earnings for the sixth quarter in a row, as the smartphone pioneer's shift to the higher-margin software business paid off.

The Canadian firm also said today it expects to be profitable on an adjusted basis for the second year in a row, and generate positive free cash flow in the year ending February 2018.

Ontario-based BlackBerry has focused on building a robust software business after scrapping production of its once-iconic smartphones, which lost favor with the arrival of sleek and fully-touchscreen handsets. 

The company outsourced the development of its smartphones last year, signing a deal with Indonesia's BB Merah Putih to make and distribute new BlackBerry-branded devices.

It has also signed similar deals with China's TCL and India-based Optiemus Infracom. 

The company said adjusted revenue from the software and services unit, which includes mobile device management products and the QNX industrial operating system, rose 12.2% to $193m in the fourth quarter ended February 28, from the preceding quarter. 

QNX is crucial to BlackBerry's efforts in the self-driving vehicle industry. 

The company already has a partnership with Ford to develop autonomous driving software, and CEO John Chen hopes to forge such deals with carmakers around the world.

BlackBerry said it received more than 3,500 enterprise customer orders in the quarter, an increase of 16% from the last quarter. 

"Looking ahead to fiscal 2018, we expect to grow at or above the overall market in our software business," Chen said in a statement. 

The company's net loss narrowed to $47m or 10 cents per share in the fourth quarter, from $238m or 45 cents per share, a year earlier. 

The prior-year quarter included a loss of $127m related to the sale of certain assets.

Excluding one-time items, the company said it earned four cents per share. Analysts on average had expected the company to break even, according to Thomson Reuters.

BlackBerry said its quarterly operating expenses nearly halved to $229m. 

Revenue fell about 38% to $286m. On an adjusted basis, revenue was $297m, beating analysts' average expectation of $289.3m.