i want to copy folder1 to the folder2.now folder1 consists of many folders and files also and so on..How can i program that all the files and folders will copy to the Folder2.I know the logic to copy a single file to a folder..
Similar problems in other platforms often use recursion.
Save some time and use the Jakarta FileUtils.copyDirectory()
Related
I have seen many example in SO how to move files from assets. All of them copy files one by one, not as part of a sub folder, i.e. here.
Is it possible to move a sub folder to a target location? If I have more thousand small files then it seems faster, than treating each file independently.
I want to add some HTML files in my program that can be update later.
I want to add these files in assets folder but I can't rewrite files when downloaded.(eclipse)
The assets folder is inside of you package - obviously you can't edit that.
Download such updates to your applications data directory. You'd then have to check in code if there is a file in the data directory, and if not use the one in assets.
I want to add my one file (example mp3) inside an apk so that when user start that application for the first time it should copy that file into phone memory.
Can someone give me some suggestions regarding how to do this?
Try putting the mp3 file in the assets/ folder. if your project doesn`t have one, create one on the same level as your res/ folder. Then, when the app runs, save the file to the sd card.
Have try to put your file into raw or asset folders.because when AAPT packaging for .apk with .class then its focuse goes to res folders and then at last to manifest file...so when you puts your file into these folders then these files takes their space into .apk.
And use a variable to know your Application is installed for very first time then make folders(where you want) to copy that file...
can i create folders, besides raw folder, for storing different kind of files?
For examples, my application need to count all the images put in a folder.
So, I need a specific folder for images only, and other folders for sounds, for .txt etc!
But when i tried to create a new folder, I couldn't reach it :(
It is just a hunch, but you might have more luck using the assets folder instead. You can certainly use it to store embedded web sites which have subfolders.
In general you cant create custom resource folders. But you can use assets dir and place your resources there. You can make as much subfolders in assets dir as you need. But android won't help you to manage your files in assets dir. Read this.
I'm reusing my iphone resources, I have myriads of resources which have many subdirectories
I'm reusing much of native code aswell, I understand that to open assets we MUST provide relative path for ex if I have file name test1.png in assets/subdir1/subdir2/subdir3/test1.png
I have to mention whole of the relative path, As I already said I'm using much of native code so is there any way I can just access asset files using just the filename without full relative path "test1.png"? Or if this is not possible is there anyway we can logically structure our resources but the folder name actually doesn't exist physically.
I understand that to open assets we MUST provide relative path for ex if I have file name test1.png in assets/subdir1/subdir2/subdir3/test1.png I have to mention whole of the relative path
With AssetManager and methods like open(), you would not have the assets/ portion of the relative path. In your example, you would use open("subdir1/subdir2/subdir3/test1.png").
As I already said I'm using much of native code so is there any way I can just access asset files using just the filename without full relative path "test1.png"?
Of course not. You might have 10,000 files named test1.png in your entire assets/ tree -- we need to know which of those to open.
Moreover, AFAIK, native code has no access to assets.
Or if this is not possible is there anyway we can logically structure our resources but the folder name actually doesn't exist physically.
Whatever you physically put as your directory tree in assets/ in your project is what you will need to use when accessing them through AssetManager. If you do not want to have to deal with subdirectories with AssetManager, do not create subdirectories inside of assets/