Properties 파일 관리에 3가지 방법이 있다.

  1. 별도 Properties 파일을 생성하여 관리
    1. Properties 파일을 프로그램 코드로 생성하여 설정 저장 / 불러오기
    2. Properties 파일을 외부에서 생성하여 Assets / Resouce 폴더에 넣고, 읽어들이기
  2. 기존 생성 local.properties 파일을 이용

Properties 사용 이유

유의 사항

구현 방법 (1번 방식)

// Java

// Option 1. File Path Load
File file = new File("$DIRECTORY", "$FILE_NAME");
if(!file.exists()){ return ""; }

// Option 2. Assets
Resources resources = context.getResources();
AssetManager assetManager = resources.getAssets();

try {
	Properties properties = new Properties();

	// Option 1. File Path Load
	FileInputStream fis = new FileInputStream(file);
	properties.load(fis);

	// Option 2. Assets
	InputStream inputStream = assetManager.open("$FILE_NAME");
	properties.load(inputStream);

	properties.getProperty("$KEY", "");
} catch (IOException e) {
	Log.i("Properties", "No properties available");
}
// Option 1. File Path Load
val file = File("$DIRECTORY", "$FILE_NAME")
if(!file.exists()){ return }

// Option 2. Assets
val resources = context.getResources()
val assetManager = resources.assets

try {
	val properties = Properties()

	// Option 1. File Path Load
	val fis = FileInputStream(file)
	properties.load(fis)

	// Option 2. Assets
	val inputStream = assetManager.open("$FILE_NAME")
	properties.load(inputStream);

	properties.getProperty("$KEY", "")
} catch (ex : Exception) {
	Log.i("Properties", "No properties available")
}

구현 방법 (2번 방식)