Question

I have two arraylists of type String and integer named temparrlist and sizelist, respectively.
Now I need to serialize these to an XML file.
I have successfully written temparrlist, but how can I write sizelist at the same time (one element of temparrlist above one element of sizelist)?
Thank you.

my present code is as follows

                            for ( String msg:temparrlist  ){

                                serializer.startTag("", "files");
                                serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true);
                                serializer.startTag("", "filename");
                                serializer.text(msg.toString());
                                serializer.endTag("", "filename");

                                Log.d(TAG, msg.toString()+ ".....WRITEN");
                                serializer.endTag("", "files");
                            }
Was it helpful?

Solution

instead of

 for ( String msg:temparrlist  ){

use

 for (int k=0; k<temparrlist.size(); k++) {
   String msg=temparrlist.get(k);
   Integer num=sizelist.get(k);
   ...
   serializer.text(msg.toString());
   serializer.text(num.toString());
   ...
}

assuming both lists are of the same size.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top