Reputation: 171
I would like to check if the current operating system is linux or android during runtime with native C. Is it possible? Because I have to execute different code depending on the OS.
Upvotes: 2
Views: 976
Reputation: 671
To ensure program runs on Android you can check environment variables named ANDROID_ROOT
and ANDROID_DATA
. Usually they are present and refer to /system
and /data
folders.
C:
You can use getenv
function from stdlib.h
:
getenv("ANDROID_ROOT");
getenv("ANDROID_DATA");
CLI:
$ env | grep ANDROID_
Upvotes: 2