F
F
foonfyrick2021-02-19 16:59:57
Android
foonfyrick, 2021-02-19 16:59:57

If the code in the version is deprecated?

If the code is deprecated, then you just need to check the version through Build.VERSION.SDK_INT <= Build.VERSION_CODES.M
and execute all the code further in brackets, and if it is more than this version, then copy the whole code and paste it into the else block?
That is, 2 almost identical large pieces of code should turn out? For example, I have a database creation of 20 lines of code, 2 of them are deprecated, so in the first block of code I write 18 lines of code, and in the else I write all 20?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
GavriKos, 2021-02-19
@foonfyrick

No. Decompose, divide into classes-methods and so on. Copypasta is evil

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question