Search code examples
androidkotlinandroid-jetpack-composeandroid-jetpackandroid-compose-textfield

How to Display text file (.txt) in jetpack compose


How to Display text file (.txt) in jetpack compose.

Explanation:

Need to show (.txt) file on the screen using Jetpack compose


Solution

  • Just read text into some value

    val text = File("example.txt").readText()
    

    Thus, all text from your file will be in that string value.

    And create @Composable text function with this value

    @Composable    
    Text(text = text)