19 May 2009 @ 10:39 PM 

So I had a silly idea to create a game for the Android operating system. It started out innocently enough, but my developer instincts took over and I just had to have the saving/loading of a player done before moving on with the rest of the game. The only problem was I could not figure out why Android would throw a fit whenever I tried to create a file. I looked everywhere online and no one could shed an insight to my NullPointerException. Feel free to skip my rant and read the last paragraph for the solution.

I spent more weeks on this than I care to admit. To my defense I didn’t work that much since my frustrations prevented me being able to deal with it for too long at one time or in back to back days. Indeed it was most frustrating, the log was not detailed enough, the stack trace offered no further assistance and without more details I could not provide a better search query to google to find my answers.

Luckily my determination and my belief that when something isn’t working when it should; it’s not me, it’s them. I have witnessed many of my peers utter disbelief that software and framework vendors can do no wrong. They believe wholeheartedly that they simply are not programming correctly; and that I am arrogant for believing it’s not me, it’s them. My arrogance is not unfounded; I happen to be proved right all too often. I would rather not, however; as I would rather have tools that just work. But I digress, let me get to my point.

I was tryign to create a simple .xml file so that I could serialize an object to the file system for storage. I figured an easy task for saving and storing player data. Much simpler than the SQLlite database alternative. I created a FileService for my game. I have been a .net developer for 2 years now and I have grown accustomed to splitting out my classes as often as possible. Seperating my code into logical objects to keep my code clean and organised.

My fileservice sole purpose was to create files, save players to them, check if files already exist, and return a list of all players. I could not do any of these. It seems the file system java developers perfer is a clusterfuck of directories. That’s just a quirk and not the real issue. The real issue is that my FileService could not create a file. An exception is throw with a nullpointer exception. best I could find out was that the operation failed; well no shit. There was no end to the combinations I tried to create a damn file and none of them worked and none of them gave me anymore detailed information.

I pulled up the API demo, and ran it. Success. Wait, what? It worked fine and my code was just like theirs; until it finally hit me that I had a seperate class doing the File IO operations. So on a hunch I placed my file creation in the main class and presto! I can create FILES! I don’t know why but it works, it does and I’m finally able to press on. Organization be damned, I just want to get this program started before I quit it. Up next, figuring out to check if a file exists. Did I say the directories were a clusterfuck? Where, oh where did my new file go …

Posted By: boyd21
Last Edit: 19 May 2009 @ 10:41 PM

EmailPermalink
Tags
Categories: Android, Programming


 

Responses to this post » (None)

 
Tags
Comment Meta:
RSS Feed for comments

 Last 50 Posts
Change Theme...
  • Users » 3
  • Posts/Pages » 30
  • Comments » 0
Change Theme...
  • VoidVoid « Default
  • LifeLife
  • EarthEarth
  • WindWind
  • WaterWater
  • FireFire
  • LightLight

GeekPub



    No Child Pages.