Take the 2-minute tour ×

There is an application, in which I have to take data through JSON and use this data in different parts of my application. What is the best way to do this? I mean, it doesn't seem efficient to me, - to pud data in bundle and then add extras from bundle to different intents. Is there something like shared preferences, but only for my app, so from every place within application I can retrieve the data I need, but this data is not visible to other applications? Thanks!

share|improve this question

4 Answers 4

up vote 1 down vote accepted

You can use sqlite database, files or Shared preferences, Look at this Android - Data storage or try this Tutorial.

share|improve this answer

it seems you are searching for android application object.

here is an so post which has the solution you are looking for.

Android: How to declare global variables?

share|improve this answer

Shared Prefs are only for your app (unless you change the mode, PRIVATE is the default) and can be accessed from all your activities. If its alot of data you might consider using a SQLite Database.

share|improve this answer

First, I would not suggest you using shared preferences, if you need efficient way yo get your data. Shared preferences is something to keep your small (i.e boolean or int) values which would actually represent preferences. Why? Because SharedPreferences are slow. I would recommend you to check this out:

  • Use Shared Preferences for primitive data
  • Use internal device storage for private data Use external storage for large data sets that are not private
  • Use SQLite databases for structured storage

That's what Google recommends you to do. If you want your data to be private, I would recommend you to use Mode Private and to keep your data in a hidder ( ./data ) folder in your application package folder. But remember, that if you really want to get something, you actually will get it, so do not keep private server passwords etc there

share|improve this answer

Your Answer


