Skip to content

Using Content Provider #42

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sonalm opened this issue Mar 2, 2012 · 4 comments
Closed

Using Content Provider #42

sonalm opened this issue Mar 2, 2012 · 4 comments

Comments

@sonalm
Copy link

sonalm commented Mar 2, 2012

How can we use contentProvider with the package? when i m trying it, it says unable to get the MyContentProvider.

@developernotes
Copy link
Member

Hello sonalm,

You can use custom ContentProviders, you only need to extend the android.content.ContentProvider will using the android-database-sqlcipher SQLiteDatabase in the implementation. We have a simple example of one that you can see here:

https://github.com/sqlcipher/sqlcipher-android-tests/blob/master/src/main/java/net/zetetic/ZeteticContentProvider.java

Can you take a look at this and compare with what you have? Can you share your stacktrace?

@n8fr8
Copy link
Collaborator

n8fr8 commented Mar 7, 2012

We are also reworking our NoteCipher sample to use a ContentProvider, based on the Android SDK's latest NotePad sample. The new version is here:

https://github.com/guardianproject/notepadbot/tree/v2

specifically: https://github.com/guardianproject/notepadbot/blob/v2/src/info/guardianproject/notecipher/NoteCipherProvider.java

still figuring out the best way to pass the key/passcode to the content provider however!

@developernotes
Copy link
Member

Hi sonalm,

Were you able to use a ContentProvider with any of the above?

@huttneab
Copy link

@n8fr8

Once the DB has been opened, does it still need the password for each call to getReadable/writeable database? It looks like according to the implementation (https://github.com/sqlcipher/android-database-sqlcipher/blob/master/src/info/guardianproject/database/sqlcipher/SQLiteOpenHelper.java) it doesn't.

My question is why not just keep the singleton pattern when using a content provider and just pass null to each of the get read/write database methods? If it's open it'll work otherwise it will do the same thing it does now. This way you don't have to cache the password.

I may be missing something about how content providers work, but in the case of a password protected provider it can't be accessed by another app w/o the user opening the protected app and entering the password anyway. So, it's safe to assume the DB is open if we're granting access to another app (i.e. launching a view intent).

Also, I've read on Oracle's site that storing passwords as strings is bad form since they are immutable. They recommend char[] and using Arrays.fill(array, ' ' ) to zero them out. Apparently, string = null is not sufficient and system.gc cannot be relied on to move fast enough. They were general Java guide lines, maybe Android is different?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants