tags:

views:

141

answers:

1

Hi, I have an sqlite file inside my iPhone app. I want the users to be able to export and import the file again, directly from the app to their desktop, for backup purposes. But I don't want them to directly access the sqlite file or the data from anywhere other than the iPhone. How do I convert the file to a proprietary format that is unreadable? Is there any facility within objective-c that will let me achieve this?

Thanks.

+3  A: 

You probably shouldn't actually attempt to port the data between a sqlite database and some proprietary format. I can't see a good reason for actually modifying the sqlite database directly unless you already have some format in mind that you can easily store the data in. Other than that, you're not going to find some generic data storage format that you can simply move your data from the sqlite database into – that's what the database is meant to be in the first place (generic data storage, that is)!

It already seems unlikely that typical users would have the incentive or the know-how to actually read or modify a sqlite database. You could try to obfuscate the fact that it is a sqlite database by changing the extension to something arbitrary. Steps beyond that (compressing the file, encrypting the file in some way) would all depend on how much you actually care about the user not being able to access the data outside your application. However, your worries seem fundamentally unfounded (in my opinion), and I don't think you should worry too much about users trying to dig into and modify a sqlite database unless you have some specific unstated reason for believing this.

Sbrocket
+1 There is no such thing as a "proprietary format that is unreadable." If it is readable by your program (in order to restore), then it is by definition readable. If you're trying to obfuscate the data for some reason, you should explain what kind of attacker you think you will be facing so that you can pick a level of protection that is appropriate. But it is not possible to ultimately protect data or programs that the user has on his own computing hardware.
Rob Napier
Thanks for that. My reasons were fairly mundane ... I want to eventually offer a desktop companion to my iphone app. I was thinking that if I let users download the sqlite file to their desktop, they can easily use an SQLite editor, like the firefox extension "SQLite Manager", to edit the file, making my desktop a bit redundant. But you're right ... it doesn't make sense to obfuscate the file, just for this purpose. Maybe renaming is good enough.
z s