Android: What's the better practice, using a global string or intents with extra data?

On a current Android project, I pass some data between a couple activities. I was just curious if there is a best practice on sending data between activities. I have a string that will be updated/appended based on the results of one activity, then used for a Facebook share two activities later. Should this string be set as a global static string, then shared, or should I pass the string using intent.PutExtra?

The global string is probably less code, but means another static variable. Alternatively, the intent Extra is fine, but seems repetitive since it's being passed through a couple activities. Either way will work, just would like to know if one is preferred above another.


In my view, only the Intent will work. On Android your application has to be prepared for the event it is killed (for example, an incoming video call puts it into background and also consumes a lot of memory so the background apps are killed). When Android restores your app, it restarts the Activity that was showing and resends the Intent that started it, because these are saved to persistent storage. But the state of other classes (including their static variables) is not saved, and if you don't save them, is lost/reset.

Need Your Help

DataGrid won't update ViewModel

wpf mvvm wpfdatagrid

I've got a datagrid which is bound to an ObservableCollection of the ViewModel below. The Datagrid will display all values correctly, so the binding seems to be working, but if I change some value ...

Distributing executable JARs depending on LGPL code license compilantly

java maven licensing executable-jar lgpl

I got a Java project I don't want to publish under a Gnu license. (MIT, but nevermind.)

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.