Android pw Input for SQLcipher

57 views
Skip to first unread message

Spider

unread,
Oct 21, 2015, 3:47:53 PM10/21/15
to SQLCipher Users
For testing purposes I hardcoded the pw into getWritableDatabase, now I want to allow users to create the pw when users first open my app. I'm pondering how to pass the pw users create to my getWritable found in my adapter class, since my getWritable is called several times and I don't want to pass the pw every time, the same thing for my constructor class.

What I tried is to pass the it using an intent, but since my adapter class isn't an activity, I can't use getIntent. Or can I?

Also, I asked on stackoverflow, but I was confused about the answer I got, because the answer below, didn't show how PASSWORD is initialized in the adapter class.

SQLiteDatabase database = SQLiteDatabase.openOrCreateDatabase(databaseFile, PASSWORD, null);

Nick Parker

unread,
Oct 21, 2015, 5:10:00 PM10/21/15
to SQLCipher Users

Hello Spider,

You might consider creating a singleton class that wraps creating your adapter class. This will allow you to minimize the creation of the adapter class for performance reasons and provide an easy way to access the SQLiteDatabase instance.

--


You received this message because you are subscribed to the Google Groups "SQLCipher Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sqlcipher+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Nick Parker

Spider

unread,
Oct 22, 2015, 8:58:23 AM10/22/15
to SQLCipher Users
Oh really? There isn't an easy way like in this example where Commonsware has https://commonsware.com/Android/Android-5.1-CC.pdf? On page 1437 (pdf p 1482), where he uses a content resolver to pass the password? The issue I had with this was I couldn't override the call method in my db class.

Separate question, if I'm not explicitly creating a db file in assets, does the db file get created automatically? Or how does that work?

Nick Parker

unread,
Oct 22, 2015, 9:42:40 AM10/22/15
to SQLCipher Users

Hello Spider,

There are many approaching you can consider, it will just come down to a design decision for your application in terms of managing resources. The database file will be created (unless the file name is ":memory:") when it does not already exist.

You received this message because you are subscribed to the Google Groups


"SQLCipher Users" group.
To unsubscribe from this group and stop receiving emails from it, send an

email to sqlcipher+...@googlegroups.com <javascript:>.


For more options, visit https://groups.google.com/d/optout.

Nick Parker

--


You received this message because you are subscribed to the Google Groups "SQLCipher Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sqlcipher+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Nick Parker

Reply all
Reply to author
Forward
0 new messages