0

So I have a really simple project:

class MainActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
    val bundle = ActivityOptionsCompat.makeCustomAnimation(applicationContext, android.R.anim.fade_in, android.R.anim.fade_out).toBundle()
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)
    val myObj = File("C:\\Users\\user\\Desktop\\k.txt")
    val myReader = Scanner(myObj)
}

and I have a "k.txt" file on my desktop. Whenever val myReader = Scanner(myObj) comes it throws a:

 Caused by: java.io.FileNotFoundException: C:\Users\user\Desktop\k.txt (No such file or directory)

why is that?

thanks for any help!

1
  • Add your file in res/raw/k.txt and then access inside the app. Commented Apr 6, 2022 at 6:27

2 Answers 2

1

You can not access storage computer

You coppy file in internal storage or external storage ( Phone Storage or SD card Storage)

Next step : Read file internal storage

Hope it`s fully

Sign up to request clarification or add additional context in comments.

Comments

0

You can't directly open or create file object from you local machine.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.