aspose file tools*
The moose likes Android and the fly likes  ERROR/AndroidRuntime(706): java.lang.RuntimeException: Unable to start activity Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Mobile » Android
Bookmark " ERROR/AndroidRuntime(706): java.lang.RuntimeException: Unable to start activity " Watch " ERROR/AndroidRuntime(706): java.lang.RuntimeException: Unable to start activity " New topic
Author

ERROR/AndroidRuntime(706): java.lang.RuntimeException: Unable to start activity

Pramod P Deore
Ranch Hand

Joined: Jul 15, 2008
Posts: 629

Hello everybody, I have write one application that writes data to the text file, but when I run application it throws following exception
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.micro/com.micro.MyProject}: java.lang.NullPointerException

what's wrong in my code.

MyProject.java file contains following code



and I have .txt file under src/com/micro/setting.txt file.
following is error part from Logcat file.




Thanks

Life is easy because we write the source code.....
Dave Brown
Ranch Hand

Joined: Mar 08, 2005
Posts: 301
Where are you setting the 'con' member ?

It looks like there is no context being passed to the Toast call, hence the null pointer exception..

Try changing



to




Regards, Dave Brown
SCJP 6 - [url]http://www.dbws.net/[/url] - Check out Grails Forum
Dave Brown
Ranch Hand

Joined: Mar 08, 2005
Posts: 301
or even just change your

Toast.makeText(context, "Settings not saved",Toast.LENGTH_SHORT).show();

to use 'this' instead of 'context' then you don't need to pass in the context into the method, unless you are planning on calling that method from other Activitys/Dialogs...

Pramod P Deore
Ranch Hand

Joined: Jul 15, 2008
Posts: 629

But still it gives the same error.
Pramod P Deore
Ranch Hand

Joined: Jul 15, 2008
Posts: 629

Now I will not get any exception but still the data is not saved under settings.txt file.
Pramod P Deore
Ranch Hand

Joined: Jul 15, 2008
Posts: 629

Hello Everybody, now I think data is stored under
data/data/com/micro/Settings.txt file ,(because Now size of Settings.txt is increased,)but I don't understand how to see content of this file. And when I will install this application under phone then where I will get this file.
Dave Brown
Ranch Hand

Joined: Mar 08, 2005
Posts: 301
If you are storing application settinings, any reason you're not using the Preferences API rather than rolling our own?

Dave
Monu Tripathi
Rancher

Joined: Oct 12, 2008
Posts: 1369
    
    1

Pramod P Deore wrote:Hello Everybody, now I think data is stored under
data/data/com/micro/Settings.txt file ,(because Now size of Settings.txt is increased,)but I don't understand how to see content of this file. And when I will install this application under phone then where I will get this file.

It is stored there because you chose to do so when you said: openFileOutput("settings.txt",MODE_PRIVATE); Read the documentation of the afore mentioned method.
It will be stored under same location when you install your application on the phone, I think. Note that, you will not be able to browse to this folder on the phone unless you have logged in as root.

To see the contents of the file, try pulling it out of SDcard onto your development machine. (Use adb pull or DDMS for this).

If you are just persisting some settings, you should consider using the Preferences API as was mentioned by Dave.

[List of FAQs] | [Android FAQ] | [Samuh Varta]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ERROR/AndroidRuntime(706): java.lang.RuntimeException: Unable to start activity