A charging algorithm of lithium ion battery comprises: at least one charging stage before the battery voltage reached a maximum charging voltage; at least one final charging stage after the battery voltage reached said maximum charging voltage, said final charging stage can be lasting for a period of time or can be transient; said maximum charging voltage in each cycle is not greater than an absolute highest charging voltage of respective battery design or chemistry; said maximum charging voltage in each cycle is not less than a lowest charging voltage; state of charge at the end of last discharging is measured and recorded; wherein said maximum charging voltage for a new charging is variable and determined by said state of charge at the end of said last discharging characterized in that said maximum charging voltage of last charging is recorded; and in that said maximum charging voltage for a new charging is further determined by said maximum charging voltage of said last charging, wherein two thresholds of state of charge are preset, wherein one is at a higher state of charge level named capacity-excess, and one is at a lower state of charge level named capacity-low, wherein said state of charge at the end of said last discharging can be measured or determined by any one of: battery impedance, battery loaded voltage or working voltage, battery open circuit voltage, directly discharging of the battery and measuring the capacity, wherein if said state of charge at the end of said last discharging is not less than said higher threshold of capacity-excess, then in the next charging de-elevate said maximum charging voltage to be lower than said last charging but not lower than said lowest charging voltage, wherein if said state of charge at the end of said last discharging is less than said lower threshold of capacity-low, then in the next charging elevate said maximum charging voltage to be greater than said last charging but not greater than said absolute highest charging voltage, wherein if said state of charge at the end of said last discharging is less than said higher threshold of capacity-excess and not less than said lower threshold of capacity-low, then in the next charging use the same maximum charging voltage as said last charging. at least one charging stage before the battery voltage reached a maximum charging voltage; at least one final charging stage after the battery voltage reached said maximum charging voltage, said final charging stage can be lasting for a period of time or can be transient; said maximum charging voltage in each cycle is not greater than an absolute highest charging voltage of respective battery design or chemistry; said maximum charging voltage in each cycle is not less than a lowest charging voltage; state of charge at the end of last discharging is measured and recorded; wherein said maximum charging voltage for a new charging is variable and determined by said state of charge at the end of said last discharging characterized in that said maximum charging voltage of last charging is recorded; and in that said maximum charging voltage for a new charging is further determined by said maximum charging voltage of said last charging, wherein two thresholds of state of charge are preset, wherein one is at a higher state of charge level named capacity-excess, and one is at a lower state of charge level named capacity-low, wherein said state of charge at the end of said last discharging can be measured or determined by any one of: battery impedance, battery loaded voltage or working voltage, battery open circuit voltage, directly discharging of the battery and measuring the capacity, wherein if said state of charge at the end of said last discharging is not less than said higher threshold of capacity-excess, then in the next charging de-elevate said maximum charging voltage to be lower than said last charging but not lower than said lowest charging voltage, wherein if said state of charge at the end of said last discharging is less than said lower threshold of capacity-low, then in the next charging elevate said maximum charging voltage to be greater than said last charging but not greater than said absolute highest charging voltage, wherein if said state of charge at the end of said last discharging is less than said higher threshold of capacity-excess and not less than said lower threshold of capacity-low, then in the next charging use the same maximum charging voltage as said last charging.