skip to Main Content

So I have this code where I want to get some files in a certain app directory, but on android 11, this app directory is not the same as the old versions, how do i modify my code to check this and get all versions right directories:

```val bool = sharedPref.getBoolean("dwaBool",false)

    val oldPath = if (bool){
        Constants.STATUS_LOCATION_DW
    }else{
        Constants.STATUS_LOCATION
    }

the right directory for android 11 is in a "const val" called "STATUS_LOCATION_AVERS"

2

Answers


  1. you can use this snippet

    val oldPath = if (Build.VERSION.SDK_INT >= 30){
           // android 11 or higher
            Constants.STATUS_LOCATION_DW
        }else{
            Constants.STATUS_LOCATION
        }
    
    Login or Signup to reply.
  2. BuildConfig.VERSION_CODE gives the current version integer number of the app.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search