tags:

views:

21

answers:

1

I would like to use self defined Environment variables in my source code. I use System.getenv() to do this and the code line looks like this. Log.d("MyTest","== MyEnv " + System.getenv("AP") + " ANDROID_ASSETS:" + System.getenv("ANDROID_ASSETS"));

before I execute my code I define my AP variable with export: export AP="12345" and the this is my output of set command

ANDROID_ASSETS=/system/app
ANDROID_BOOTLOGO=1
ANDROID_DATA=/data
ANDROID_PROPERTY_WORKSPACE=9,32768
ANDROID_ROOT=/system
AP=12345

...

Then I execute my code and I get this line from logcat

D/MyTest( 5363): == MyEnv null ANDROID_ASSETS:/system/app

The value for my defined Environment variable is null. Any suggestions on why it didn't work?

A: 

Export command works for one session only, not for a whole system. You can't set environment variables that way. getprop/setprop doesn't work neither.

I had similar problem and found that easiest way to pass some arguments from console is to do something like:

echo "12345" > /sdcard/myapp/args/AP

Then read this file from Java.

Brutall
I did try setprop/getprop with no results too. I guess I'll have to use something like this. Thank you
Michalis