java


What is Android's SharedPreferences equivalent in Java?


I'm trying to port an Android application to a Java desktop application. The android application is using a SharedPreferences object to store some data. Is there an equivalent in Java of this class?
Check the Preferences API out. It has the same idea and use cases as the SharedPreferences.
Check out the java.util.Properties class.
You have to manage reading and writing the file, but it might be good enough!
SharedPreferences is something specific to Android.
Making it a desktop aplication you will have to implement your own storage system to store your preferencies in an implementation dependent backing store.
You can achieve this using the Core Java™ Preferences API
There many ways to store data in Java application. Depends on the scope of data you store, is it on session scope, application scope or anything else.
If you are looking something like SharedPrefereces, maybe you can read/write the data to System/User Environment. I don't know if it will match you need.
public class Env {
public static void main (String[] args) {
for (String env: args) {
String value = System.getenv(env);
if (value != null) {
System.out.format("%s=%s%n",
env, value);
} else {
System.out.format("%s is"
+ " not assigned.%n", env);
}
}
}
}
I suggest XStream.
It allows to manage properties as simple Java POJOs and store it to a XML file (Just what SharedPreferences are, an XML file) for persistence and retrieval.
Plain simple.

Related Links

How do I update a JLabel in a JPanel?
Java: toLowercase messes up the unicode symbols
Using long in place of int causes extra cases of overflow in java. Why?
Basic query regarding String
Building up Java Web Application with JPA for Wildfly fails?
Please install android target 19 (the android newest sdk) when adding android platform in Cordova
Sending data between java server and android client
TransactionRequiredException Executing an update/delete query
JSP Internal server error
Auth with Unirest JAVA
Jar executable with sqlite driver
Improve JDBC Performance
Paragraph leading inside table cell
Java: plot points based on distances
JPQL - List of all items in collection member of JPA entity
How to copy directory that's injected as Resource?

Categories

HOME
yii2
openlayers
gitlab
amazon-ec2
angular-material
homebrew
syntax
jpeg
ojdbc
serverspec
mapserver
static-libraries
carthage
openrefine
google-static-maps
invantive-sql
jqwidget
visual-composer
emulator
autoconf
cloudhub
web-sql
sox
excel-2007
emgucv
h2db
chromebook
react-css-modules
web-api-testing
strncpy
primitive
newline
nouislider
tinymce-4
protovis
mozilla
environment-modules
sequential
revolution-slider
appfabric
serve
dynamics-crm-2013
sharefile
optix
gulp-sourcemaps
nand2tetris
fakeiteasy
google-datalayer
chain-builder
revapi
csound
mako
arrow-keys
lync-client-sdk
redundancy
query-performance
jquery-filter
sts-springsourcetoolsuite
jwplayer7
moveit
hill-climbing
python-stackless
rvest
ipconfig
ptrace
marching-cubes
retina
ideamart
sysinternals
device-orientation
apache-commons-net
typekit
winddk
phalanger
applescript-objc
issuu
neolane
project-planning
responsive-slides
hyprlinkr
balanced-payments
farseer
commoncrypto
access-rights
inbox
bulkloader
batterylevel
eventual-consistency
orchardcms-1.7
factory-method
simba
bitsharp
nsnetservice
dice
first-responder
windows-phone-7.1.1
enter
reddot
assembly-loading
joyent
netbeans-7.1
visitor-statistic
suppress
vc90
web-architecture
substrings
brewmp
sef
mediarss
defensive-programming
w3wp
ntvdm.exe

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App