0
    val file = File("C:\\Users\\kim01\\Desktop\\android\\serverpractice\\app\\src\\main\\res\\drawable\\img.jpg")
   
    if(file.exists()){
        println("iamhere!!!!")
    }
    else{
        println("not")
    }

in kotlin, i used assign file with a absolute path from my image(by path copy) but always said "not" i used \ as / or relative path like drwable/img.jpg but not working what is the problem in this case?

mike
  • 21
  • 1
  • 1
    Is this in an Android app? An Android app can't read a file from your computer. That doesn't really make sense. If you want to read resource at runtime, use the usual way of accessing resources in Android. If you want a raw file to work with, put it in the [assets directory](https://stackoverflow.com/questions/18302603/where-to-place-the-assets-folder-in-android-studio) and use `context.assets` to access the file. – Tenfour04 Nov 01 '21 at 15:19

0 Answers0