Android Password Manager

Android Password Manager

Contents
  • Details
    • SQL Initialization overhead
    • Database opening and creation mechanism
    • Updating and inserting data
    • Fetching all entries
    • Fetching an entry by a field
    • Conclusion
  • TODO
  • Bugs
  • Downloads

This is an adaptation of PasswordSafe by Steven Osborn (released under the Apache License) which is basic password manager for the Android platform. The source code have been adapted to use db4o instead of SQLite which makes the handling of persistence much more intuitive while still being fast.

Details

The application basicallystores login information for websites such as url, username and password in a secure way using 128 Bit AES Encryption. The user must provide the correct password in order to access the application and this password is then used to encrypt/decrypt the data.

This is a sample video of the db4o powered application running on the Android Emulator:

http://www.youtube.com/watch?v=UFSD44AcBwM

If you check the source code (see the end of this page) you'll see that the the DBHelper class (SQLite persistence) has been replaced by the Db4oHelper class (db4o persistence). Let me now show you some of the differences between handlingpersistence with db4o and SQLite.

SQL Initialization overhead

This is the SQL code that you need to initialize the password manager for SQLite (table names, table creation commands, etc):

And this is the equivalent db4o code:

As you might notice, you don't have to preinitialize your schema with db4o! (with db4o your object model is your schema and refactoring is handled gracefullyor even automatically for simple cases)

Database opening and creation mechanism

With SQLite youneed two different method calls, one for the creation of the database and another one for opening it:

while with db4o you just call openFile() and it will create or open depending on whether the DB exists:

Might not sound like a big deal but less code is cleaner code!

Updating and inserting data

As with any relational database with SQLite you need to pass insert or update commands according to the situation (not to mention that you must also construct the SQL string reflecting all fieldswith no errorsfor the commands to work properly):

And this is the equivalent db4o code:

Do you see any difference? db4o is indeed a one-line-of-code storage database. db4o detects automatically whether the object is new or preexisting and updates or inserts accordingly (we just call this a store operation). Note that here we provide the next id for the object manually but db4o can also be configured to autoincrement a field.

Fetching all entries

Note the manual object relational mapping that we have to do with SQLite:

and forget about it with db4o:

Notethat in this simple query we're asking for all PassEntry objects and sorting the result by the field "id" (while there's no sorting in the SQLite example). In this case the query is performed via SODA.

It couldn't be simpler!!!

Fetching an entry by a field

Here the code for fetching entries by Id when using the SQLite version:

and here's the db4o version using one of thethree query systems of db4o (in this case we use Query by Example aka QBE instead of SODA):

Much shorter an cleaner!

Conclusion

I hope you've realized about the benefits of db4o with this short demonstration (and this is just the basic stuff that you can do with db4o). Do you want to take persistence to the next level in your app too? Download db4o for Java or .NET now. It's FREE!!!

Other resources:

  • db4o tutorial
  • Installation instructions
  • Resources for developers
  • Download db4o for Java or .NET

TODO

  • Replace the custom encryption algorithm with XTEA(which will provide database level and io encryption instead of field encryption)
  • Provide search capabilities (in order to filter the entries by name)

Steve's Password Safe projectis under active development on Google Code (more TODOs here):

http://code.google.com/p/android-passwordsafe/issues/

Bugs

  • There's an error when trying to edit a url in the website field of the password entry editor

Downloads

Password-Safe-Db4o.Zip (Details)
Download (1.1MB)

Original "Password Safe" by Steve Osborn (without db4o) can be downloaded here

更多相关文章

  1. 代码中设置drawableleft
  2. android 3.0 隐藏 系统标题栏
  3. Android开发中activity切换动画的实现
  4. Android(安卓)学习 笔记_05. 文件下载
  5. Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
  6. 技术博客汇总
  7. android 2.3 wifi (一)
  8. AndRoid Notification的清空和修改
  9. Android中的Chronometer

随机推荐

  1. [Android(安卓)UI界面] Android(安卓)UI
  2. android启动优化
  3. Android(安卓)Studio实现人民币与美元的
  4. android实现签名功能
  5. Android7.0中文文档(API)-- AdapterView.On
  6. android屏幕截图
  7. 关于Android的Activity的onCreate多次调
  8. 好久米有碎碎念啦 android how to click
  9. Android(安卓)中使用MediaRecorder进行录
  10. 【Android】_MyContentProvider_外部访问