Set system properties for Android application
Asked Answered
T

1

9

Can I (in the Manifest file or somewhere else) set system properties for my Android application?

I want to use a library that can be configured using system properties, and being able to just use that mechanism would reduce the amount of code I need to write.

Tryma answered 5/3, 2011 at 4:48 Comment(1)
Android seems to have no equivalent to the java -D option for presetting a system property before the code runs, e.g. no manifest directive. Other negative answers about the java option approach: here and here.Aubarta
C
4

Yes, you can set system properties for your app.

String myprop;
System.setProperty("MYPROP", "4");
myprop = System.getProperty("MYPROP");
Log.i(TAG, "MYPROP: " + myprop);

Here, you set and geta system property from the Java "world". To access it from the C/C++ world (NDK), ie your lib, check out this post: Calling a java method from c++ in Android.

Caskey answered 17/8, 2012 at 19:20 Comment(1)
Yes, but that would be in code. I want to reduce the amount of code that I need to write by having it in a file somewhere. (Of course, your suggestions makes it possible for me to write a small helper class that sets properties from a file)Tryma

© 2022 - 2024 — McMap. All rights reserved.