Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 268
Registered: ‎08-19-2009
My Device: Bold 9700
Accepted Solution

Reading SQLite DB when Media Card Encryption is enabled

Hello,

 

My application packages a pre-existing SQLite file as a resource, which it stores at //sdcard/databases/[appName]/db.sql.

 

My problem is when users have their devices set to encrypt the Media Card, I can put the file on the card but my app cannot access it or decrypt it, and therefore I'm unable to use it.

 

Is there a way I have my app decrypt the .sql file, or prevent it from encrypting on the card in the first place? This seems like it could be a common use case.

 

I've found a funky work around by renaming the .sql to .mp3, but again this will only work if the user has Media Files encryption set to "Disabled." This is non-ideal, obviously.

Developer
Posts: 268
Registered: ‎08-19-2009
My Device: Bold 9700

Re: Reading SQLite DB when Media Card Encryption is enabled

I haven't been able to find a solution yet. Are there any thoughts or ideas on this?

Highlighted
Retired
Posts: 571
Registered: ‎06-25-2010
My Device: Z10
My Carrier: Vodafone

Re: Reading SQLite DB when Media Card Encryption is enabled

This is a known issue. Fortunately the following workaround should resolve the issue for you:

 

Instead of download the .db file and then opening it directly in SQLite using the DatabaseFactory class, proceed as follows:

 

1.  Create the database(file) using the DatabaseFactory class.
2.  Close the database.
3.  Open a file connection to the database file that was created in step 1 and 2
4.  Truncate the file to 0 by calling FileConnection.truncate(0)
5.  Download the database over the network and write out the data to the file created above using FileConnection.openOutputStream()
6.  Close the file connection
7.  Now, re-open the database using the DatabaseFactory class and your SQL should work as expected.

 

Creating the database file using the DatabaseFactory class results in the file *not* being marked as requiring encryption.

 

Hope this works for you.

--------------------------------------------------------------------------------------------
Feel free to press the like button on the right side if you liked my attempts to help :-)
And please mark posts as solved if you think I found the solution or set you on its path. Thanks!
Follow me on Twitter: @mdwrim
Developer
Posts: 268
Registered: ‎08-19-2009
My Device: Bold 9700

Re: Reading SQLite DB when Media Card Encryption is enabled

Thanks very much.