Wednesday, May 23, 2012

android copy folders from assets to internal device app data folder

I created two folders inside assets ("images" and "files") both containing some files. I need to copy it when first launch to data/data/com.relatedPackage.myApp keeping same name and same file contents. I am an iOS programmer and that os does not allow to copy whole folders so, in android, which is the proper method to do it?



Possible to copy whole folder "images" (including its files) from assets to data/...? That would be great.
If not, should I create first empty folders using same names at data/... and then copy files from assets to current? In this case would be necessary to list all files inside folders in order to copy to data/...? Thank you.





Make text height 100% of div?

I'm trying to make the text 100% height of a div but it doesn't work. It just becomes 100% of the body { font-size:?; }. Is there any way to make it follow the div height?
The div height is 4% of the whole page and I wan't the text to follow it when you rezise/change resolution.



best regards,
Daniel





Serving different XML content on the same web

I don't know if this is the suitable place to ask this question, so I am sorry if I am doing it wrong. I think this is not a duplicate question. If it is, I am sorry too.



Currently, I have a web app which takes its content from a unique XML document. The URL is "http://webapp.com/"



The problem is that now I have to create a second version of the web which uses a new different XML document, so I have to put them different URLs, something like the following:



http://webapp.com/activities

http://webapp.com/stages



How can I have all my sources on just one directory on server-side (I suppose it's better to maintain, the resources are cached better, etc...) but with these 2 URLs pointing to the folder and making the PHP loades the XML depending on the URL?



I suppose I have to change the .htaccess file to redirect to that folder, but how can I tell what XML I must load? And the user must see on the search bar the URL he used, for example "http://webapp.com/activities"



Can anybody help me please?
Thanks for all





How to press back button in android programatically?

I my app i have a logout functionality. If user clicks logout it goes to home screen.Now i am exiting my app by pressing back button. But what i want is i need to exit automatically(i.e Programatically) as same like as back button functionality. I know by calling finish() will do the functionality. But the thing is it goes to the previous activity.



Thanks for your help guys





Spring @Transactional does not work in JUnit test?

I am using Spring 3.2 and JUnit 4.



My Dao class is as follows:



@Transactional public class SomeDaoImpl implements SomeDao {



The update operations on this work if executed directly from web application. However, I am seeing that junit integration tests that exercise the update methods do not actually persist the changes. Is something rolling the transactions back when junit methods are executed?





Best practices for API backwards compatibility

I'm working on an iPhone/iPad/Android app which communicates with a JSON API.



The first release of the version of the app is complete, and now additional phases of development are taking place. In the additional phases, the app needs to integrate with a new version of the API and allow the user access to additional features such as new screens or modified behaviour within existing screens. The app does however need to be backwards with previous versions of the API.



What is the best practice for tackling such a requirement?
I could of could do checks throughout the code:



if (APIVersion == 1) {

} else if (APIVersion == 2) {

} else if (APIVersion == ....) {

}...


But I'm concerned about the scalability of this approach.
The factory method comes to mind but I'm not sure how far this would get me.



Thanks,
Mark





array variable in awk

A=(aaa bbb ccc)    
cat abc.txt | awk '{ print $1, ${A[$1]} }'


I want to index an array element based on the $1, but the code above is not correct in awk syntax. Could someone help? Thanks!