File.copyTo (and copyToAsync) extremely slow on Android. e.g. 1/2 second per tiny XML file. Help?

On first launch, my app copies about 100 tiny XML files from application dir to storage dir. It takes about 35 seconds. That is clearly an issue. It takes about 1/100th of a second on any other platform. I've switched to copyToAsync() so that the user doesn't bail, but still this is like using a dial-up modem! Anyone have any thoughts?

Hi all,
I ran into the same problem on Android: File.copyToAsynch is terribly slow. For 200 files of about 42mb total, it took my Samsung Note 10.1  85 secs to copy from app dir to storage dir! (I have to copy the files to storage dir to be able to read modification date, which is not present in app dir, for an update scheme.)
The solution I ended up with is very simple:
Iterate recursively over folder that you want to copy.
For each file that is not a directory, open the file (using FileStream) , read the bytes, write the bytes to a file on the target directory and close the streams.
This took only 5 secs for the same 200 files / 42 mbs. As this happens only on first run of my app, this is very acceptable.
Here is my code :
var folder:String = "content/";//supply your folder here
var src:File = File.applicationDirectory.resolvePath(folder);
var goal:File = File.applicationStorageDirectory;
var bytes:ByteArray = new ByteArray();
var stream:FileStream = new FileStream();
var iterate:Function = function(dir:File, path:String):void
                                        var files:Array = dir.getDirectoryListing();
                                        for each(var file:File in files)
                                                  if (file.isDirectory)
                                                            iterate(file, path + file.name + File.separator);
                                                  else
                                                            bytes.clear();
                                                            stream.open(file, FileMode.READ);
                                                            stream.readBytes(bytes);
                                                            stream.close();
                                                            var dest:File = goal.resolvePath(path+file.name);
                                                            stream.open(dest, FileMode.WRITE);
                                                            stream.writeBytes(bytes);
                                                            stream.close();
iterate(src, folder);
This could easily be reworked to work asynch of course.
Hope this works for other people as well.
Reinier

Similar Messages

  • I just bought a 2 gig USB, AND ITS EXTREMELY SLOW HEEEELP!!

    i just bought a 2 gig usb and its EXTREMELY slow, it takes like 1 hr to transfer 700 mb, thats ridiculously slow, is there anything i can change for it to become faster?
    its wierd, i can tranfser files from the usb to my mac pretty quick but from my mac to the usb it takes a LONG time, any ideas?
    PLEASE HELP

    Extended Hard Drive Preparation
    1. Open Disk Utility in your Utilities folder. If you need to reformat your startup volume, then you must boot from your OS X Installer Disc. After the installer loads select your language and click on the Continue button. When the menu bar appears select Disk Utility from the Installer menu (Utilities menu for Tiger or Leopard.)
    2. After DU loads select your hard drive (this is the entry with the mfgr.'s ID and size) from the left side list. Note the SMART status of the drive in DU's status area. If it does not say "Verified" then the drive is failing or has failed and will need replacing. SMART info will not be reported on external drives. Otherwise, click on the Partition tab in the DU main window.
    3. Set the number of partitions from the dropdown menu (use 1 partition unless you wish to make more.) Set the format type to Mac OS Extended (Journaled.) Click on the Options button, set the partition scheme to GUID (only required for Intel Macs) then click on the OK button. Click on the Partition button and wait until the volume(s) mount on the Desktop.
    4. Select the volume you just created (this is the sub-entry under the drive entry) from the left side list. Click on the Erase tab in the DU main window.
    5. Set the format type to Mac OS Extended (Journaled.) Click on the Options button, check the button for Zero Data and click on OK to return to the Erase window.
    6. Click on the Erase button. The format process can take up to several hours depending upon the drive size.

  • Adobe reader xi i am running 2 display screens and when i have a file open and go to print the print page opens on my second screen.  How can I get adobe reader to just display on one screen?

    adobe reader xi i am running 2 display screens and when i have a file open and go to print the print page opens on my second screen.  How can I get adobe reader to just display on one screen?
    I want the capability of adobe reader to just run on one screen.

    I had the same problem.
    Try this.
    https://igppwiki.ucsd.edu/groups/publichelpwiki/wiki/a1538/Howto_Disable_Acrobat _as_the_Safari_PDF_Viewer.html

  • I just recently upgraded my itouch from 4.1 to ios5, and updated to itunes 10.5. when isynced my music files,ebooks and other apps, all is working except when im trying to sync my video files. it says, canot be synced as cannot be played on this ipod.help

    i just recently upgraded my itouch from 4.1 to ios 5, and updated to itunes 10.5. but when i synced my music files,ebooks and other apps, all is working except when im trying to sync my video files. it says, canot be synced as cannot be played on this ipod. but those are the same files that i have when i was using the old 4.1 version and its syncing just fine.. the itunes advanced tab "create iphone or ipod version" is not working either so i cant convert it to be xferred and synced. what can i do to have my video files synced?

    i had the same problem but i just got a new video converter and made it convert videos to ipod/iphone format and then put them into itunes. i would suggest GOM encoder as the encoder can convert them and then once they're finished converting, put them automatically into your itunes for you. from there you can just sync them to your ipod.

  • HT1660 My "itunes library" folder is empty.  My libray music (prior to upgrading itunes) is now in an .xml file in my itunes location under my music.  How do I extract/convert this .xml file to a Itunes database and restore my Itunes music library??? Than

    My "itunes library" folder is empty.  My libray music (prior to upgrading itunes) is now in an .xml file in my itunes location under my music.  How do I extract/convert this .xml file to a Itunes database and restore my Itunes music library??? Thanks, Tom

    Empty/corrupt library after upgrade/crash
    Hopefully it's not been too long since you last upgraded iTunes, in fact if you get an empty/incomplete library immediately after upgrading then with the following steps you shouldn't lose a thing or need to do any further housekeeping. In the Previous iTunes Libraries folder should be a number of dated iTunes Library files. Take the most recent of these and copy it into the iTunes folder. Rename iTunes Library.itl as iTunes Library (Corrupt).itl and then rename the restored file as iTunes Library.itl. Start iTunes. Should all be good, bar any recent additions to or deletions from your library.
    See iTunes Folder Watch for a tool to catch up with any changes since the backup file was created.
    When you get it all working make a backup!
    tt2

  • My iphone 4 died even though it had plenty of battery, and shows no sign of life until i put it on to charge where it shows the apple sign every now and then but just turns off again after a few seconds.....HELP!!!!

    my iphone 4 died even though it had plenty of battery, and shows no sign of life until i put it on to charge where it shows the apple sign every now and then but just turns off again after a few seconds.....HELP!!!!

    Could be a defective battery, you should get it checked by visiting an Authorized Apple Service Provider or Apple Store next to your place.
    Find an Apple Authorized Service Provider

  • FCP 6.0.1 Running and previewing extremly slow

    Ever since I upgraded to 6.0.1 FCP is running extremly slow.
    In my current project, I brought in a HDV QT.mov that needed to be Chroma Keyed and color adjusted. Previewing the chroma keyed file looks horrible (all jagged) unless I render it. That takes time. Then I added a piece of stock DV footage under that, blurred the background and it played back like crap until I rendered it. More time. And so on.
    I can't make any adjustment and see how it looks without rendering.
    When I was working in 5.1 FCP I was able to add all type of files and zip right through them pretty much. Now I can't seem to get my settings right or something...so as I apply different effects or filters I can never see on the fly how it looks without rendering it first. Then of course...if it's not right...I tweak it again but can't see how that looks until I render it again.
    All my video files resides on a RAID that I created from 2 of my internal drives and it also is my scratch & render disk.
    It's eating my lunch on production time.
    Any suggestions Please.

    You could try setting the render in the sequences you work with to ProRes. Found in that sequence setting's video processing tab.
    But the real fix is to not work in HDV at all. If you have an Intel mac, a capture card like the Kona LHe card will transcode your HDV directly to ProRes... or AJA's Io HD (at the high end of this workflow) will transcode the HDV to ProRes on board the box itself... The Io will take your HDMI signal directly from the camera and transcode it to anything. It starts shipping any day now.
    You're a brave soul attempting chroma keys with HDV... they are nigh on impossible to look good. But ProRes will make the rendering times go way down, and give you more real time playback of effects.
    Jerry

  • Help! MacBook Pro only boots in Safe Mode and runs extremely slow (bonus: happened in Brazil and there are no Apple stores here - I need you guys!)

    It's a MBP mid 2010. Last year it had some problems and an Apple authorised shop changed the HD and upgraded the OS from Snow Leopard to Lion. After that it seemed fine. Recently it started getting very slow and apps (e.g. Chrome, Flash) would crash. At some point it seemed stuck so I gave it a hard shutdown - bad idea. After that it would only boot in Safe Mode. I ran repar disk and repair permissions from the Disk Utility and it booted normally again but extremely slow. I upgraded to OS X 10.8.2, but didn't solve it. I tried booting with Command D to have a hardware diagnostic - it wouldn't boot and now it only boots in Safe Mode.
    All data is backed and I have an external HD (but not an OS X Disc). Ready to anything. Help please!
    Utility Disk Logs
    Repairing permissions for “Macintosh HD”
    Group differs on “Library/Java”; should be 0; group is 80.
    Permissions differ on “Library/Java”; should be drwxr-xr-x ; they are drwxrwxr-x .
    Repaired “Library/Java”
    Warning: SUID file “System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/MacOS/ARDAg ent” has been modified and will not be repaired.
    Permissions differ on “System/Library/Frameworks/CoreGraphics.framework/CoreGraphics”; should be lrwxrwxrwx ; they are lrwxr-xr-x .
    Repaired “System/Library/Frameworks/CoreGraphics.framework/CoreGraphics”
    Permissions differ on “System/Library/Frameworks/CoreGraphics.framework/Resources”; should be lrwxrwxrwx ; they are lrwxr-xr-x .
    Repaired “System/Library/Frameworks/CoreGraphics.framework/Resources”
    Permissions differ on “System/Library/Frameworks/CoreGraphics.framework/Versions/Current”; should be lrwxrwxrwx ; they are lrwxr-xr-x .
    Repaired “System/Library/Frameworks/CoreGraphics.framework/Versions/Current”
    Permissions repair complete
    Verifying volume “Macintosh HD”
    Checking file systemPerforming live verification.
    Checking Journaled HFS Plus volume.
    Checking extents overflow file.
    Checking catalog file.
    Checking multi-linked files.
    Checking catalog hierarchy.
    Checking extended attributes file.
    Checking volume bitmap.
    Checking volume information.
    The volume Macintosh HD appears to be OK.
    Verifying and repairing partition map for “ST9500325AS Media”
    Checking prerequisites
    Checking the partition list
    Adjusting partition map to fit whole disk as required
    Checking for an EFI system partition
    Checking the EFI system partition’s size
    Checking the EFI system partition’s file system
    Checking all HFS data partition loader spaces
    Reviewing boot support loaders
    Checking Core Storage Physical Volume partitions
    Updating Windows boot.ini files as required
    The partition map appears to be OK

    See this for incompatible log in items
    https://support.apple.com/kb/TS4348
    Also you can perform #1 and #2 as these occur before Safe Mode, so you just reboot again with Shift key if you need to enter Safe Mode again.
    At this point it sounds like your hard drive is dying or some sort of other hardware issue which I can only advise this.
    Try to install OS X on a external drive and boot from it, if it's fine then you know your internal boot drive is dying.
    Create a data recovery/undelete external boot drive
    You can replace your internal drive yourself.
    OtherWorld Computing is pretty good about providing drives and tool kits to perform that function yourself.
    Install/upgrade RAM or storage drive in Mac's

  • Final Cut loading and running extremely slow...

    Hi, I posted about this a few days ago but in my usual panic (work to do!) I didn't make it clear, basically, here's the problem...
    I recently had problems with FCP and generally all apps on my machine, when they loaded there was a slight pause when the icon bounced on the dock and I came across all sorts of errors, especially in FCP.
    So, I backed up the two internal hard disks, formatted them both, then Raided them as one and put all the information back from the backup.
    Since then everything's been working fine, I installed a new fresh copy of Final Cut Studio and I've done a few jobs.
    Since finishing my last job last week (which happened to be working with MP4 files, I'm not sure if this is relevant), every time I load FCP now the icon struggles to bounce and it runs extremely slow, even if it's loading a new, blank project. From my last post, someone suggested I delete the render files from the MP4 project, I did so but still no luck.
    I've run Disk Utility, Disk Warrior, no hope.
    All other apps are fine but when I run FCP it slows the whole machine down, takes forever to force quit and restart until it's back to normal.
    Next step is to re-install Final Cut Studio but even if this works, I'd like to have an idea why this has happened??? I've never had problems like this with my mac before.
    Thanks, hope this is clear and not too much!
    Alex

    I recently had problems with FCP and generally all apps on my machine, when they loaded there was
    a slight pause when the icon bounced on the dock and I came across all sorts of errors, especially in
    FCP. So, I backed up the two internal hard disks, formatted them both, then Raided them as one and
    put all the information back from the backup.
    It would have been much better to find the problem than to just move it around.
    All you have done is create a RAID where none was needed. When you moved your clone back to the RAId, you only moved all of the original problems to a new drive.
    You are probably looking at a complete scorched earth-style reformat and reinstallation of everything from scratch since you've done so much damage.
    There were a couple of things to try before you made the RAID but they would have been found by asking some questions and searching in the Mac OS10 forums.
    bogiesan

  • File transfers are soooo extremely slow in Parallels! How to speed up?

    For transferring files between osx and parallels, i use the tool which is dilivered with paralles, but is is sooooo extremely slow here. It took 3 minutes too transfer a 2 mb file.
    Is it possible to acces the OSX partition in windows by using Macdrive from mediafour? I also did this when i was using bootcamp. But now i like to swich fast betwee XP and OSX, so i started using Parallels
    Any other suggestions how to speed up?
    Maybe a partition which i can acces from both systems?

    Yea, just installed, as they told in the help file. Then i shut down the Quest OSX, and shared some folders with the configuration editor. After that i started Windows again, and there was a new "parallels shared files" shortcut on the windows desktop. In there i could see all the folders i had shared. Just like it was told in the manual.
    When i drag a file from the "parallels shared files" location, then it starts copying. It is only soooo slow.
    I am sure that it is not a speed or memory or HD problem! I have 2 gig memory, and Quest OS has 0,5 gig and OSX has 1.5 gig. So that should be far enough for both! I have no other programms running (in windows and OSX), so there is no CPU speed short. My HD is just free from work, Quest OS and Windows are note using it, because there are no app's running, except Parallels:P
    Are there maybe other possibilites? Can i open the image file in OSX, and drop files in there, or any other solutions. Look out for your help!
    Parallels does also not respond to my e-mail, i send it 4 days ago!

  • IPhoto 9.5.1 and Mavericks extremely slow and hangs

    I upgraded to Mavericks and bought iPhoto 9.5.1 upgrade from the app store. Now, iPhoto is extremely slow in loading thumbnails. Once it loads a page or two, then it is fast to scroll the thumbnails it has already loaded, but as you go further back in time, it needs to load all the thumbnails. It eventually hangs. When I reboot the application, it doesn't remember the previous thumbnails and is again extremely slow. This version is way to slow to use and is actually unusable. It also doesn't show any faces in the face collection frames, and when you click on them, it opens up blank outlines, then when you click on these, it brings up the original photo with all the faces named. So the faces feature has major issues as well.
    I never had any problem with the previous version of iPhoto. I am using a mid-2010 macbook pro with 8 g of ram. Anyone else have this problem and is Apple aware of the problems with this version?
    Thanks.

    Where is your iPhoto Library stored? Have you tried rebuilding the Library?

  • Oracle ODBC and DAO extremely slow

    Hi
    I'm using Microsoft DAO 3.6 with an Oracle ODBC connection (version 9.2) in an VB6 application.
    Opening an updateable dynaset is extremely slow, I have measured the performance with Oracle ODBC, Microsoft Oracle ODBC and Microsoft SQL-Server ODBC as follows:
    Oracle ODBC: 1952 ms
    MS Oracle ODBC: 360 ms
    MS SQL-Server ODBC: 40 ms (connection to a MS SQL-Server)
    If I use the SQLpassthrough option the result is about 10 ms in all 3 cases, but the dynaset is readonly !
    The testing program is as follows:
    Option Explicit
    Private Declare Function timeGetTime Lib "winmm.dll" () As Long
    Private Sub Form_Load()
    Dim wsdata As DAO.Workspace
    Dim db As DAO.Database
    Dim dbconn As String
    Dim rs As DAO.Recordset
    Dim start As Long
    dbconn = "ODBC;DSN=AdhocitORA;UID=adhocit;PWD=adhocit;"
    Set wsdata = DBEngine.Workspaces(0)
    Set db = wsdata.OpenDatabase("", False, False, dbconn)
    start = timeGetTime
    Set rs = db.OpenRecordset("Select * from Afdeling", dbOpenDynaset)
    rs.MoveLast
    rs.MoveFirst
    rs.Close
    Set rs = Nothing
    MsgBox "Time " & timeGetTime - start
    End Sub
    Is there any setting in the Oracle ODBC, that need to be adjusted ??
    Erling

    Why are you doing a moveLast followed by a moveFirst? That's going to force Oracle to retrieve all the records in the recordset. If there are a lot of records, you'll probably see a benefit if you increase the prefetch in the Oracle ODBC DSN configuration.
    Justin

  • Flash player plays online video and games extremely slow

    I had my pc reformatted two days ago  but prior to that I never had problems like this. playing streaming videos and games gives me extreme pain! especially watching videos on youtube, the video loads fast but it plays like in slow motion and almost frame by frame, so I waited for the video to load completely but when I played it, it's still the same it was annoyingly slow and the play buttonl sometimes is not responding! I install and reinstall the latest version of flash but nothing happened I used IE8 and Mozilla Firefox 3 but both have problems.... but when playing games and videos saved on my hard disk all is very much fine, it plays fast and no fuzz. I also noticed that  sites that uses flash also have lags and plays animations slow... I need help badly! Im using windows xp, pentium 4, 2.80 ghz, 512ram and nvidia geForce 7300 SE / 7200 GS internet connection is 100.0mbps dsl connection, I still have 30gb free space on c: so I wonder why is it like that!  Please help!

    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.com/kb/Safe+Mode

  • [solved] Opera,firefox and wget extremely slow (dial-up style)

    Hi there,
    this is the first time i've tried Arch Linux (64bit), so bare with me please if i've got something stupidly wrong.
    The Problem: Both Opera and Firefox are both extremly slow when opening websites. It "feels" like some kind of DNS problem, because the initial time before anything loads is quite long, but after that it goes quite quickly (though still a bit sluggish).
    But here's the catch: Ping and loading websites in links work both perfectly fast.
    For example accessing google.com in firefox: 40 seconds until page is loaded. In links about 1 second.
    Wget seems to suffer from the same problem:
    wget google.com
    --2008-12-22 03:29:23-- http://google.com/
    Resolving google.com...
    It just takes a lot of time.
    Can anyone help me with this?
    Last edited by Deathcrow (2008-12-22 12:48:26)

    Ok, i had a hunch:
    http://wiki.archlinux.org/index.php/IPv … the_Module
    Adding the line to modprobe.conf solved the Opera and Firefox issues.
    The behaviour of wget stays the same. Its still very very slow.
    Programs that seem to be affected:
    -wget
    - ssh
    - openntpd
    Edit: Alright, the remaining issues were real network issues on my side. They are fixed now.
    Last edited by Deathcrow (2008-12-22 12:49:03)

  • I updated my itunes and lost my entire library!!  I found it again as a .xml file.   How do I get it back onto my desk top?

    I updated my itunes and lost my entire library.  I found it again as a .xml file
    How do I take this file and get it to look like my library used to?
    (I am dumb with computers and need  step by step instructions)
    Thanks!

    Se my response on this post:
    ]                                  Screen Message"File iTines Library.itl cannot be read because it was created by a newer version of iTunes" What is this and how can it be fixed?                    
    They do not appearon the right-had side of your post.

Maybe you are looking for

  • Creative Cloud updates failed

    Hi, I have been having the same problem with updates to CC software that many others have - namely the updates to certain packages fail with the message: "Installation failed. Error Code: U44M1P7" The so called "solution" posted here http://helpx.ado

  • How do you print a monthly calendar showing week numbers?

    Is there a way to display and the print the week numbers in the monthly view in iCal. I can get the calendar to start on the first day of the wekk, Monday, but I can not find any way to show the week numbers in a column to the left of the Monday colu

  • Soundtrack Pro with Blackmagic Intensity Pro Card

    Hi Just wondering if anyone was using STP with the Blackmagic Intensity Pro card to monitor video on a TV? If so, whta are your experiences and especially does STP allow you to continue using your selected audio device (MOTU Ultralite over Firewire f

  • Create and Password protect a pdf using VBA?

    Hi, I have a requirement to generate and password protect a pdf using a Microsoft access application (version 2007). I have seen plenty of code examples for generating the pdf, but is it possible to password protect the pdf programmitically? Thanks!

  • Ipod 80G classic Restore Loop

    A few months ago i accidentally dropped my ipod onto its corner. after that it would freeze and not work properly. eventually it set itself to disk mode. i have no idea how or why. it just did. now when i connect it to itunes it says i need to restor