/configer

a simeple Configuration file operation class,replace sharepreferences for android In some cases ,easy to use

Primary LanguageJavaApache License 2.0Apache-2.0

configer

a simeple Configuration file operation class,replace sharepreferences for android In some cases ,easy to use

how to use

Add it in your root build.gradle at the end of repositories:

allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
	}
}

Step 2. Add the dependency

dependencies {
        implementation 'com.github.yangyongzhen:configer:v1.0'
}
package com.yangyongzhen.demo;
 
import androidx.appcompat.app.AppCompatActivity;
 
import android.os.Bundle;
import android.util.Log;
 
import com.yangyongzhen.configer.Configer;
 
public class MainActivity extends AppCompatActivity {
    private final String TAG = "MainActivity";
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //更改存储目录为mydir,默认为/Android/data
        Configer.setDirPath("/mydir");
        SysCfg config = SysCfg.getInstance();
        //加载
        config.load();
        Log.d(TAG,config.toString());
        //赋值
        config.setVer(500);
        config.setUserName("yangyongzhen");
        //存储
        config.save();
        //再次读取测试
        SysCfg config1 = SysCfg.getInstance();
        config1.load();
        Log.d(TAG,config1.toString());
 
    }
 
}