ABX3-type organic-inorganic hybrid halide perovskite materials have been recognized as promising candidates for optoelectronic applications. However, poor stability of organic-inorganic hybrid perovskite hinders their forward long-term utilization and hence an effective strategy is needed to replace the organic part with an inorganic cation. Herein, all inorganic CsPbI3 nanowires with a diameter of 50-100 nm are synthesized on fluorine-doped tin oxide glass via a simple solution-dipping process, which are further transformed into CsPbBr3 nanowires through a solution-phase halide exchange method. A phase change from non-perovskite to perovskite structure is observed during the ion substitution process of I − by Br − , which is elaborated by X-ray diffraction, absorption and photoluminescence spectra. We for the first time apply the as-formed CsPbI3 and CsPbBr3 nanowires into perovskite solar cells, yielding power conversion efficiency of 0.11% and 1.21%, respectively. The inorganic CsPbBr3 nanowire solar cell shows impressive stability which still remains 99% of the initial power conversion efficiency even after 5500 h aging.