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. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
Developer
nik_bhat
Posts: 29
Registered: ‎09-23-2008

Interesting FileSystem Question!

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.

Please use plain text.
Developer
rafo
Posts: 507
Registered: ‎07-15-2008

Re: Interesting FileSystem Question!

[ Edited ]

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.

Message Edited by rafo on 09-23-2008 03:46 PM
----------------
if your issue solved set "Solution" mark at the relevant post
Please use plain text.
Developer
Doctor
Posts: 73
Registered: ‎07-15-2008

Re: Interesting FileSystem Question!

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

Please use plain text.
Developer
rafo
Posts: 507
Registered: ‎07-15-2008

Re: Interesting FileSystem Question!

To add text file to cod module do the following.

 

  1. Run JDE
  2. Create a new project
  3. Specify module name in project properties
  4. Add text file to the project.
  5. Build the project
  6. Sign the cod file. I am not sure that it is necessary, because it is only data container, but sign it to avoid any possible errors when accessing this cod module outside.
----------------
if your issue solved set "Solution" mark at the relevant post
Please use plain text.
Developer
Doctor
Posts: 73
Registered: ‎07-15-2008

Re: Interesting FileSystem Question!

Thanks for the quick reply.

:smileyhappy: 

Please use plain text.
Administrator
MSohm
Posts: 12,956
Registered: ‎07-09-2008
My Carrier: Bell

Re: Interesting FileSystem Question!

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

http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800620/How_To_...

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Found a bug? Report it using the Issue Tracker
Please use plain text.
Developer
nik_bhat
Posts: 29
Registered: ‎09-23-2008

Still NOT Clarified!

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.

 

 

Please use plain text.
Developer
Doctor
Posts: 73
Registered: ‎07-15-2008

Re: Interesting FileSystem Question!

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

Please use plain text.
Developer
rafo
Posts: 507
Registered: ‎07-15-2008

Re: Still NOT Clarified!

Check this link

 

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.

----------------
if your issue solved set "Solution" mark at the relevant post
Please use plain text.
Developer
rafo
Posts: 507
Registered: ‎07-15-2008

Re: Still NOT Clarified!

Your application will read JAD properties and use them as an initial settings. Your app may store these settings from JAD file on the SDCard when it runs.
----------------
if your issue solved set "Solution" mark at the relevant post
Please use plain text.