0

I'm using sharedPreference in Android, but in which memory it will be stored like heap memory or stack memory? How much amount of data we can store in sharedPreference for better experience.

Pang
  • 9,564
  • 146
  • 81
  • 122
Paru
  • 57
  • 1
  • 7

2 Answers2

1

SharedPreferences are stored in an XML file and and they are stored in heap memory it throw a Memory Exception when SharedPreference data exceed 1.42 MB. you can refer to this stackoverflow link for more details. Shared Preferences "limit"

Community
  • 1
  • 1
Rohan Sharma
  • 374
  • 4
  • 11
0

Stack is used for static memory allocation and Heap for dynamic memory allocation, both stored in the computer's RAM .Therefore shared preferences are heap based.

Variables allocated on the heap have their memory allocated at run time and accessing this memory is a bit slower, but the heap size is only limited by the size of virtual memory .

Remario
  • 3,813
  • 2
  • 18
  • 25
  • What is the stack? It's a special region of your computer's memory that stores temporary variables created by each function (including the main() function) – Remario May 19 '17 at 01:40
  • Shared preferences were designed store a maximum of 1.45mb like floppy disks back in the days! – Remario May 19 '17 at 01:42