Click here to Skip to main content
15,879,239 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hello Guys, i am working on Android project and am using android studio for it my question is I have AdMob id in my string.xml and I have a PHP file also I want to get AdMob id from PHP and store in main activity variable and put this variable value in string


What I have tried:

<string name="admob_app_id">here i want my variable value</string>
Posted
Comments
David Crow 29-Jun-18 19:13pm    
Have you tried:
getResources().getString(R.string.admob_app_id);
Member 9983063 30-Jun-18 15:42pm    
i dont wanna get string.xml value in mainactivity i want mainactivity variable value in string.xml
David Crow 30-Jun-18 21:15pm    
You can't add to the strings.xml file at runtime. What exactly are you trying to do that would necessitate such? Surely we can recommend a better solution.
Mike V Baker 2-Jul-18 11:26am    
You actually can write to a file so you could get strings.xml and write it to the phone's storage (you'll have to ask the user for storage permission). Then you can read in the xml, make changes and write it out.
You mentioned PHP. Is this PHP file running on a server someplace? You want to retrieve the value by calling the PHP file and then write it out to the xml? Perhaps local storage in a database might be more appropriate (secure). I would not suggest that you do this with your resources file. If you want to store a value that you read at runtime then create your own file or use a database.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900