Thursday, 29 October 2020

Can I set different edition for top variable in Android Studio?

I know I can set different value in different resource file for one item, you can see Code A, Code B and Code C.

I hope to do the same work for top variable, just like Code D and Code E, can I do that?

Code A

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <bool name="isProVersion">false</bool>
</resources>

Code B

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <bool name="isProVersion">true</bool>
</resources>

Code C

build.gradle
android {
    ...
    productFlavors {
        free {
            applicationId "info.dodata.voicerecorder"
        }

        pro {
            applicationId "info.dodata.voicerecorder.pro"
        }
    }
    ...
}

Code D

package info.dodata.voicerecorder.bll

import android.content.Context

var name="Hello For Free"

Code E

package info.dodata.voicerecorder.bll

import android.content.Context

var name="Hello For Pro"


from Can I set different edition for top variable in Android Studio?

No comments:

Post a Comment