I'm having requirement like if the device connected to system has android sdk version above 2.1 then it should take the sdcard path as /sdcard and if the device has version above 4.1 then it should take the sdcard path as /mnt/sdcard.
So how to find out device version which is connected to system through command line whether it's 2.x versioned device or 4.x versioned?
This will give you all the information you need for an Android device.
adb shell cat /system/build.prop
You need to enable USB debugging in device settings. Optionally if permission denied message pops up, you may use following
adb root
Edit:
If you have AOSP source code, you may look into build/core/version_defaults.mk file and search for PLATFORM_VERSION tag for exact Android version.
I am not sure exactly what you want but can filter it down to two possibilities.
1) You want to via the commandline on a machine that has emulators running determine the version of android it is running. If this is the case you want to use the command:
adb shell grep ro.build.version.sdk= system/build.prop
This will return you a number you can use to determine the android version. Note you may need to add the -s flag if you have more than one emulator/device connected to point it at a specific device.
2) Within an android applicatio you want to get the android version to determine where the sdcard file is. If this is what you are looking for you are asking the wrong question, what you want to know is how do i figure out where the sdcard is on the device. In this case the answer is:
Environment.getExternalStorageDirectory();
or one of its similar methods which can be found at http://developer.android.com/reference/android/os/Environment.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With