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
Contributor
Posts: 27
Registered: ‎06-19-2012
My Device: Developer
My Carrier: None
Accepted Solution

Lock DB File to Application To Prevent Manual deletion

Hi,

 

My Application uses a SqLite database to store data. But once the Sqlite is created by the application, the user can just close the application, browse the filesystem to reach the .db file and then delete it.

 

I want to know if there is any way i can prevent the user from deleting the .db in such a way. Only the application should be able to delete the database. 

 

Something like what we have in windows wherein if a program or software is using a file and then we try maually deleting it, we get a dialog saying "Unable to delete. It is being used by another person or program".

Developer
Posts: 19,633
Registered: ‎07-14-2008
My Device: Not Specified

Re: Lock DB File to Application To Prevent Manual deletion

Welcome to the forums. 

 

I beleive if your application is currently using the database, it will not be deleted for the same reason as in Windows, i.e. the OS knows that someone is using the file and will lock it then.  But I have not specifically tested this so I suggest that you try it yourself. 

 

But just like Windows, I don't believe that there is a way to stop the user deleting it when the application is not running (i.e. the file is not busy).  And of course you can't stop the user taking the SD Card out. 

 

How big is this database?  You might be able to copy it as a byte array to PersistentStore, and so have a backup copy. 

Contributor
Posts: 27
Registered: ‎06-19-2012
My Device: Developer
My Carrier: None

Re: Lock DB File to Application To Prevent Manual deletion

I have tested it..and i can say that in blackberry, you can delete the file, while still in use. 

 

The Database is quite huge and Persistent storage may not be an option.

 

Any other ideas? 

Developer
Posts: 19,633
Registered: ‎07-14-2008
My Device: Not Specified

Re: Lock DB File to Application To Prevent Manual deletion

" have tested it..and I can say that in blackberry, you can delete the file, while still in use. "

 

That is a bit scary.....

 

I have, when I had sequential files I didn't want deleted, marked them as hidden, but I'm not sure you can do that to an SQL database. 

 

Aside from that, sorry no idea, hope someone else has. 

Contributor
Posts: 27
Registered: ‎06-19-2012
My Device: Developer
My Carrier: None

Re: Lock DB File to Application To Prevent Manual deletion

Thanks Anyways..