res > value > string 에 이용약관이나 라이센스 내용등을 넣어두고 textview 에 넣어서 사용중
'string to large' 라는 오류가 발생 했다.
잘 쓰고있는다가 왜지??! 했는데 구글링 해보니 여러 답변들이 있었지만 요약 하면.
문제
APK 파일에 32,767바이트(UTF-8로 인코딩) 이상의 문자열을 가질 수 없다.
솔루션
assets 폴더에 텍스트 파일을 만들어서 읽어오면 된다.
assets 폴더에 텍스트 파일을 읽은 메소드
fun getAssetsTestString(fileName: String): String{
val termsString = StringBuilder()
val reader: BufferedReader
try {
reader = BufferedReader(
InputStreamReader(assets.open(fileName))
)
var str: String?
while (reader.readLine().also { str = it } != null) {
termsString.append(str)
termsString.append('\n') //줄 변경
}
reader.close()
return termsString.toString()
} catch (e: IOException) {
e.printStackTrace()
}
return "fail"
}
출처:
https://stackoverflow.com/questions/51732252/textview-shows-string-too-large
TextView shows STRING_TOO_LARGE
I have been trying to set a large string (25k+ characters) to a TextView for a while now but I've been getting a "STRING_TOO_LARGE" output. I read somewhere that setting the string in run time mi...
stackoverflow.com
Reading a txt file and outputing as a TextView in Android
I am trying to read a text file that is already saved in my directory and print it on the screen as a TextView. This is the code that I have so far. However, when I run the application, it creates a
stackoverflow.com
'안드로이드' 카테고리의 다른 글
안드로이드 코틀린 / 동적으로 리니어 레이아웃 weight 변경하기, set Dynamic weight Kotlin (0) | 2021.10.06 |
---|---|
안드로이드 코틀린 / 인터넷 연결 확인하기 API 30 (0) | 2021.10.01 |
안드로이드 코틀린 / Key was created with errors:경고: 다른 저장소 및 키 비밀번호는 PKCS12 KeyStores에 대해 지원되지 않습니다. 사용자가 지정한 -keypass 값을 무시하는 중입니다. (0) | 2021.08.13 |
안드로이드 코틀린 / 공백 체크, Null 체크 (0) | 2021.07.08 |
안드로이드 코틀린 / 프래그먼트 하이드 상태 확인 하기, kotlin fragment hide check (0) | 2021.06.10 |