In the Android API http://developer.android.com/guide/topics/data/data-storage.html#pref
It says:
Shared Preference allows you to save and retrieve persistent key-value pairs of primitive data types. You can use SharedPreferences to save any primitive data: booleans, floats, ints, longs, and strings.
Is String a primitive data type or an Object?
The string data type is a non-primitive data type but it is predefined in java, some people also call it a special ninth primitive data type. This solves the case where a char cannot store multiple characters, a string data type is used to store the sequence of characters.
Strings, which are widely used in Java programming, are a sequence of characters. In the Java programming language, strings are objects. The Java platform provides the String class to create and manipulate strings.
Primitive data types - includes byte , short , int , long , float , double , boolean and char. Non-primitive data types - such as String , Arrays and Classes (you will learn more about these in a later chapter)
Primitive types are the basic types of data: byte , short , int , long , float , double , boolean , char . Primitive variables store primitive values. Reference types are any instantiable class as well as arrays: String , Scanner , Random , Die , int[] , String[] , etc.
As far as Java
programming language is considered,
A primitive type is predefined by the language and is named by a reserved keyword.
In addition to the eight primitive data types listed above, the Java programming language also provides special support for character strings via the
java.lang.String
class.
—— from The Java™ Tutorials - Primitive Data Types
So, as such in Java
books, it's not a keyword and not a primitive either. SharedPreferences
may still call it one of the primitives, but that's not from the book of Java
as such, it could be because it's one of the set of basic types like int, float, char etc we come across.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With