views:

36

answers:

2
+4  A: 

I think you're confusing the state which is saved when an Activity is paused and the data delivered to the Activity via an Intent.

You want to have something like:

Bundle extras = getIntent().getExtras();
id = extras.getLong(TasksDBAdapter.KEY_ID);

The Bundle passed to onCreate() is the Bundle you saved with the onSaveInstanceState() method and is not the extras Bundle you added to your Intent.

Dave Webb
Please look at my clarification in bold.
Mohit Deshpande
A: 

You are retrieving the extra in a very wrong way. Replace your second code snippet with:

id = getIntent().getLongExtra(TasksDBAdapter.KEY_ID, 0);
Log.i(TAG, "Id of note = " + id);

Here's what happens in this code: getIntent() returns the Intent you created in your first code snippet (the Intent that was used to launch the current activity). Then, .getLongExtra() returns the attached extra information. If no extra information with that tag and that data type (long) is found, it will return 0.

savedInstanceState is used for saving your app's state when it is shut down by the Android system under low memory conditions. Don't confuse these two.

Felix