I've been following along with the Intro to Android Apps MOOC on Udacity and have been learning a lot about good coding practices just by looking at the sample code from that course. However, today I found something a little bit puzzling:
// Third Step: Insert ContentValues into database and get a row ID back
long locationRowId;
locationRowId = db.insert(WeatherContract.LocationEntry.TABLE_NAME, null, testValues);
Why was locationRowId declared on a separate line? It seems like it would be much cleaner to change the code above to
long locationRowId = db.insert(WeatherContract.LocationEntry.TABLE_NAME, null, testValues);
Is there a particular reason for including the extra step? Or can I safely use the single-line version.
Thanks