Friday, September 13, 2019

Config Support Java in Android App

Config Support Java in Android App

1.https://mvnrepository.com/artifact/com.typesafe/config/1.2.1
 
2.See gradle part
// https://mvnrepository.com/artifact/com.typesafe/config
compile group: 'com.typesafe', name: 'config', version: '1.2.1'
 
Change this to for newer android studio
 
dependencies {    ...
    implementation 'com.typesafe:config:1.2.1'     
 
    implementation 'org.cfg4j:cfg4j-core:4.4.1' 
    ...
    } 
 
3. In Java File
 
import com.typesafe.config.Config;
import com.typesafe.config.ConfigFactory; 
 
 
private final String strSamples = readAndroidConfig("sns_service.audio.samples_per_second");
 
public String readAndroidConfig(String key){

        /* Read Config File */
        System.setProperty("config.file","/data/data/com.visteon.sns.app/sns/android-sns.cfg");
        Config config = ConfigFactory.load();
        String ssample_rate = config.getString(key);
        return ssample_rate ;

} 
 
 

No comments:

Post a Comment

Featured Post

XDP - Getting Started with XDP (Linux)