I created a custom object of type Task and I want to save it in a binary file in internal storage. Here is the class I created:
Android provides a private directory structure to each application for exactly this kind of data. You don't need special permissions to access it. The only caveat (which is generally a good caveat) is that only your app can access it. (This principle is part of the security that prevents other apps from doing bad things to you.)
If this meets you need for storage, just call getFilesDir() from whatever context is readily available (usually your activity). It looks like in your case you would want to pass the context as a parameter of readData() and writeData(). Or you could call getFilesDir() to get the storage directory and then pass that as the parameter to readData() and writeData().
One other caveat (learned the hard way). Although undocumented, I've found that sometimes Android will create files in this application directory. I strongly recommend that rather than storing files directly in this application folder you instead create your own storage directory in the application directory returned by getFilesDir(), and then store your files there. That way you won't have to worry about other files that might show up, for example if you try to list the files in the storage directory.
File myStorageFolder = new File(context.getFilesDir(), "myStorageFolder");
(I agree with P basak that DataInputStream and DataOutputStream are your best option for reading and writing the data. I disrecommend Serialization except in a very narrow set of applications where transportability is a factor as it is very inefficient. In my case objects that took 15 seconds to load via Serialization loaded in less than 2 seconds using DataInputStream.)