How to store and retrieve email id and password using SharedPreferences?

by pranav09 » Wed, 20 Jan 2010 02:07:51 GMT

Sponsored Links
 Hi all,

I am developing an application which requires to store email id and
password, so that the user can directly redirect to his home page if
the user is already exists. A few day ago i read that
SharedPreferences is used for storing and retrieving the data.

How can i use SharedPreferences concept to store and retrieve data.
Anybody have any idea to do this way? If it is possible by
understanding me through the code because i read that things but i can
not get it properly.


Other Threads

1. unable to open sync connection

I get the message "unable to open sync connection", when
compiling in Eclipse, often enough to be really annoying and
timeconsuming. The only way I can deal with it is to restart the
computer. Sometimes it comes up straight after a restart, but usually
restarting fixes it for a while. Associated with this is often a spate
of the app not responding.
     Can anyone please shed some light on this and offer tips on how
to deal with it and avoid it. Also where can we get all of this type
of information. I have purchased two books on Android but they both
seem rather patchy, certainly not comprehensive.


2. Use script to run Monkey

Hi everyone,

I guess everyone knows how to run Monkey, but we all know that Google
documentation is mediocre.  All we have is this page:

We have found the need to run our own script to manually test our
application.  For that, we would require the Monkey to send touch
events to specific points on the screen.

Since there has been ZERO support from Google, I decided to sift
though the source code for Monkey.

Here are my findings:

The source of monkey is located in: development\cmds\monkey

If you take a look at the directory, there is a file called
"example_script.txt" and following is the contents:
# Touch the android
touch down 160 200
touch up 160 200
sleep 1000

# Hit Next
touch down 300 450
touch up 300 450
sleep 1000

# Hit Next
touch down 300 450
touch up 300 450
sleep 1000

# Hit Next
touch down 300 450
touch up 300 450
sleep 1000

# Go down and select the account username
key down dpad_down
key up dpad_down
key down dpad_down
key up dpad_down
key down dpad_center
key up dpad_center
# account name: bill
key down b
key up b
key down i
key up i
key down l
key up l
key down l
key up l

# Go down to the password field
key down dpad_down
key up dpad_down

# password: bill
key down b
key up b
key down i
key up i
key down l
key up l
key down l
key up l

# Select next
touch down 300 450
touch up 300 450

# quit

Looking at the source code, the command to use a script is: adb shell
monkey -f script.txt 1

But you will notice that adb exited with code: -5.

And looking at the one of the source code that handles the parsing of
the script file,, the script simply doesn't
work because those are not the actual commands that the
MonkeySourceScript is looking for.  Now, lets take a look at the's comment header:

 * monkey event queue. It takes a script to produce events sample
script format:
 * <pre>
 * type= raw events
 * count= 10
 * speed= 1.0
 * start data >>
 * captureDispatchKey(5113146,5113146,0,20,0,0,0,0)
 * captureDispatchFlip(true)
 * ...
 * </pre>

You might think this is the actual formation with headers and the
explicit command to start the commands.  WRONG.
There is a function called readHeader() which it validates the source
script and it only scans for "count", "speed", and "start data >>".
But having the type definition there shouldn't stop you.

Whats more interesting is the commands, they are totally different:
the names and the parameter definitions are totally different.  By
looking into more code, following are the accepted commands:

DispatchPointer(long downTime, long eventTime, int action, float x,
float y, float pressure, float size, int metaState, float xPrecision,
float yPrecision, int device, int edgeFlags)
DispatchTrackball (same as DispatchPointer)
DispatchKey(long downTime, long eventTime, int action, int code, int
repeat, int metaState, int device, int scanCode)
DispatchFlip(boolean keyboardOpen)
DispatchPress(int keyCode)
LaunchActivity(String packageName, String className)
LaunchInstrumentation(String testName, String runnerName)
UserWait(long sleepTime)
LongPress() //it sends ACTION_DOWN on KEYCODE_DPAD_CENTER for 2
seconds and then sends ACTION_UP for KEYCODE_DPAD_CENTER
PowerLog //not important for this topic
WriteLog //not important for this topic

With all of this new information, I am still unable to get this
working.  Does anybody have ideas?  Or any engineer from Google?


3. Problem in sound playing in android phonegap and left swiping animation flickering problem in jqtouch?

4. Developing a new SoftKeyboard for Cupcake

5. Android 1.6 equivalent of EXTRA_GATEWAY_URI

6. Read data from database and show it in table layout form

7. GPS streams in Android to do DGPS