1

Is it possible for an activity to create xml files and write inside?, or just modify an existing xml files in the res folder?

i am trying to achieve an activity which the user can design a live wallpaper inside it, than save it into an xml file of sort, or modify an existing one (which could be better), and the wall paper service will read that xml file to apply it to the screen.

Daniel Mendel
  • 506
  • 5
  • 17
  • You can't modify the `res` folder, so you're looking for [this](http://stackoverflow.com/questions/8337602/save-xml-file-on-android-device-and-read-it). – Cat Aug 01 '12 at 19:59
  • That what you want to do is called SharedPreferences – pawelzieba Aug 01 '12 at 20:04
  • as long as i remember it is not possible to change apk file content once the app is exported. Maybe you could use the general device storage for creation and modification of the xml files? – Boris Mocialov Aug 01 '12 at 20:52
  • saying so, i understand that it is possible to add an xml file in the phone storage and customize it when needed with ease? – Daniel Mendel Aug 01 '12 at 20:55
  • yes, look here: http://www.anddev.org/working%5Fwith%5Ffiles-t115.html and do the tutorial. You can always store some 'static' files in assets folder of your project. Just find a way to write some mini editor which will allow user to modify files and see their content and offcourse the way for the application to interpret those files – Boris Mocialov Aug 01 '12 at 21:00
  • you're very welcome. Think out of the apk :) – Boris Mocialov Aug 01 '12 at 21:06

2 Answers2

0

It a bad practice to modify your code at runtime, moreover I don't think is even possible. a possible solution is to create a default layout, and then modify it using java methods, in case there are not method you should extend the View class of the object (button,imageview...).the following question might be helpful for y

Android Runtime Layout Tutorial

Community
  • 1
  • 1
Kirill Kulakov
  • 10,035
  • 9
  • 50
  • 67
  • the thing is the xml file only modifies once, after the user hit save and set as wallpaper for instance, than, it will call the service to "update" causeing it to simply read the xml file (after it got modified) just once, and just transform the data from that xml into the service – Daniel Mendel Aug 01 '12 at 20:10
  • similar to the "Settings" tab of every other live wallpaper exists, only it is modified in a stand alond activity. – Daniel Mendel Aug 01 '12 at 20:11
0

Perhaps this would help

I haven't worked with XML but I doubt it is not possible.

Eran
  • 387,369
  • 54
  • 702
  • 768
Maikel Bollemeijer
  • 6,545
  • 5
  • 25
  • 48