09-23-2008 02:45 AM
Hi,
My question relates to the file system that has been interested since 4.2. Our software used the Persistent store for storing information relating to configurations(for connecting to SAP) and log files. However, with the introduction of file systems, it would be a lot better and consistent with the other platforms we are supporting(windows mobile, smartphones)I have already migrated this to include file systems, but these questions now arise.
Question 1) We have always provided a sample configuration file along with our software on different platforms. Now,there is a need to install a sample configuration (text) file, (which the user can change when he installs our software) along with the installation of the cod files(without user intervention). Is there a way of including files (other than cod) in the alx specification? (pretty much turned the 4.6 dev guide upside down, and there seems to be no mention of it!)
Question 2) As part of the running of our software, connecting to SAP, downloading data and screens and the like, there is a log file being constantly updated with actions/errors/database updates/downloads. When the application is uninstalled from the device, these files still remain. Is there a way to delete this file when the application is uninstalled?
The key is to minimise user intervention, similar to software being installed on your desktop, no one likes orphan files/directories left after an uninstall!
Any help/direction will be greatly appreciated!
Cheers,
Nik.
09-23-2008 07:40 AM - edited 09-23-2008 07:46 AM
1. As far as I know it is not possible to install and use "bare" configuration files in blackberry OS filesystem. One exception - use microSD to store file. But it is not convenient way for mass-installation. I recommend to include your text file into another cod file and access it via path:
cod://codModuleName/fileName.txt
if cod file with your text file named: abc.cod and file named xyz.txt then path will be:
cod://abc/xyz.txt
In this case you can install this module with text file inside of Blackberry OS filesystem and access this text file from another application.
2. Most probably you're using a java.util.Vector class instance as a storage for log records. Create your own wrapper class like com.mycompany.StorageBlock and write this class instances to the persistent store. In this case when you uninstall application all data instances of classes produced by you will be removed too. java.util.Vector is not your class, and because of that the instance of this class remains in persistent store after uninstall.
09-23-2008 08:04 AM
Hi rafo,
This was really very informative. I never knew about these things. Specially about writing our own wrapper class instead of storing data in Vector, it was really interesting, too.
I would like to ask you how can we add a text file in our cod file? You mean to say, we have to manually do this after signing cod files in any of the archive utility like WinZip or WinRar? Or we have to include text file into the cod file using IDE? And how?
Thanks,
- Rohan
09-23-2008 08:14 AM
To add text file to cod module do the following.
09-23-2008 08:35 AM
Thanks for the quick reply.
09-23-2008 01:40 PM
Please note that the cod:// protocol is not supported or recommended. The following link explains how to read a file packaged within your cod file.
How To - Add plain text or binary files to an application
Article Number: DB-00148
09-23-2008 07:56 PM
MSohm,Rafo, Thanks for the reply, but it still does not solve my problem. I will explain a bit further.
Our software supports configuration files, wherein, you have sections editable sections for SAP systems, and the like. Up until now, we were using the Options Provider class combined with the PersistentStore objects to store and retrieve configuration information. When the software is installed for the first time, it also installs a vanilla configuration, that points to our SAP system. The user can change these sections via (Options ->XXX -> Configure Local Server/Configure Local Client -> Opens a screen with several options). Now, I have moved these options to a file. The software reads these options(using the FileConnection class) and uses the configuration options;;;; and from the filesystem, gives the user an option to change sections. What I wish to clarify is,
1) Is it possible, when installing the "*.cod" files, to install a vanilla config file, say SampleConfig.txt, to this path "file:///store/***/****/SampleConfig.txt. I don't want to have to go through the trouble of my library module, manually having to create this vanilla configuration file, with specific sections, on the file system. There has to be an easier way to add files to the file system when installation occurs.(As an analogy, consider what happens when you install on the desktop, a particular directory under Program Files\** with files. The user can as simply click on the file to either execute it or edit it or what ever!)
2) Rafo, no, we aren't using the Vector class for implementation of log files. Each thread(for example, a Binary File Manager, a Local Database Manager etc) gains access to the log file (which is in the persistent store), and writes information to it in the format
[Date][ThreadName] [TypeOfMessage]: [ActualMessage]. We have a formatter class, that accepts messages of type [TypeOfMessage] and [ActualMessage] from threads, and returns a string object in the above form, which in turn writes it to the persistent store.
Now, that I've started writing these String objects to a "file:///store/***/****/Log.txt", is it possible, on uninstallation, to delete this log file from the file system, as well!
Phew, hope MSohm, Rafa, anyone, you get this!
Cheers,
Nik.
09-24-2008 01:33 AM
Hi Mark,
Thanks for guiding us in a proper direction.
As mentioned in the article which you have provided the link for, we can access the text file using that. But can that file be accessed by other application or can that file be seen in file explorer of the device?
- Rohan
09-24-2008 09:43 AM
There is a description how to read parameters from JAD file.
Place your parameters into JAD file and read them in your application.
Hope this helps.
09-24-2008 09:45 AM