Tag Archives: SD Card

Uploading Files from Android (progress update 2)

Right before I left the lab yesterday, I uploaded from the Android Emulator to Octopussy successfully. Daniel was here, he’s my witness.

Today, it doesn’t work, which is super awesome. It isn’t a matter of computer goblins or anything like that though, the Android Emulator was running a pseudo-SD card which I had manually pushed my test file onto. That is the only thing that changed from yesterday to today, so something has gone wrong with the file system. I’ve been making some attempts to get away from using the SD cards for my testing, because it is a bit unpredictable.

I wrote some code to generate files based on user input, but I’m getting the same crashes from that as I do from the SDcard version. I have a feeling it has something to do with file permissions, because when I browse the emulator’s file system with DDMS, the permissions on files I’ve pushed are all weird and different from other ones on the phone. I started having some issues yesterday with command line sdcard management, and I switched to direct code/DDMS options, which is probably why it is acting all weird.

Once again I’m really hoping I can get it up and running soon! It was really exciting to see it run successfully yesterday, and pretty disappointing to have it crash today 🙁

Uploading Files from Android a success! (locally)

Shortly after my last post I actually had a pretty major breakthrough with the upload proof of concept. I managed to get my Android application (running on the emulator) to upload a file to a server on my local machine. The PHP approach to the problem ended up being the way to go. I added a post to this thread which had been confusing me for about a week. Tons of people posted saying “it worked” or “this is the client side code that worked”, but nobody simultaneously posted the PHP and Client-side snippets which worked for them.

I found the XAMPP server application very helpful as I worked on doing the initial proof of concept. It creates a server on the localhost of your machine, so you can test web code without actually deploying it on a server (which is a whole other set of headaches-the ones I currently have!). One little gotcha that Carny helped me fix is that the permissions on the directory you want to upload to – they need to be such that your ‘server user’ has permissions to write to that directory (or just chmod 777 but be aware that this is NOT the good/secure way to do it – it works if you just need to test it and set it back afterwards though).

Another interesting thing I learned today was how to add a faux-SDCard to your android emulator. Just run the commands on that site in a terminal (from your tools directory). In order for the file upload to work, you need to manually push the file to your Android’s SD Card!

Also, please note (and I’ve forgotten it twice already since learning it in that tutorial…) that the directory path given in that link is NOT what you want to put as your own eclipse path. It looks deceptively like some super-secret google pathname, a G: drive, Android, SDK_Root, etc. However, this is just the path that the creator of the tutorial happened to have on his PC. You need to insert the path to the sdcard you create!

My next task will be to get the file upload working from a real Android phone to an actual server. I’ve been working on getting the uploader.php to run on Octopussy, but so far I’m getting errors. The PHP that I set up seems to be working fine though, which is nice to see. Hopefully by tomorrow I’ll have it all up and running!