My application needs a database. The database contains only one table i.e. for password. Password will be inserted only one time, and there's no need for delete and upgrade. Can anybody help for code? For this password database, user will insert only one time, and database will be closed. And when the user inserts next time, the password will be checked against the database password.
4 Answers
Why don't you use SharedPreferences
for storing only one field??
Encrypt the password before saving in SharedPreferences
whose mode is set to MODE_PRIVATE
, and whenever you have to check , just encrypt the text user had typed, and match with SharedPreferences
This way, you'll be in ease.

- 11,231
- 7
- 46
- 81
-
sorry for my english,just i taken password from user in edit text,and how to encrypt this text string,pls help how to use this exact i m newbie in Android Development – Nilesh Jan 31 '11 at 13:13
-
you can check this out: http://developer.android.com/reference/android/util/Base64.html#encodeToString%28byte[],%20int,%20int,%20int%29 Convert your password string to a byte[] array and feed that array to this method, you'll get the encrypted String back – Aman Alam Jan 31 '11 at 13:40
This can be the duplicate of: connecting-android-application-with-any-database
The answer is:
Probably the easiest way is to use something like PHP as a middle layer, then send HTTP requests from your Android application to it. Take a look at this for more information
Also read this: how-to-connect-android-to-a-database-server
Hope this helps.
If you just need it for a single table, containing a single row, then are you sure a database is the right choice? I think saving the password to SharedPreferences
might be a better fit. Have a look at the data storage options.

- 10,910
- 5
- 39
- 62