Reduce restore method

Remove duplicate code and use constants from AppInfo.java instead of the
numbers in themselves.