You Are Here:

Community: Wiki

This page was last modified 22:37, 13 December 2007.

Using .ini Files

From Forum Nokia Wiki

In addition to an application’s document file, the application architecture provides support for an application to open, read and modify a second file. By convention, the file has the same name as the application, but has a .ini extension; hence such files are known as .ini files.

The intention is that a .ini file should be used to store global settings and preferences that are independent of the document data that the application is processing. An application can then, in principle, open a different document without affecting the existing preference settings.

In practice, applications running on mobile phones tend to use only a single document and therefore have no real need to use .ini files. In recognition of this fact, the S60 UI disables the application architecture’s support for .ini files, but it is a simple matter to restore it if necessary, by replacing CAknApplication’s OpenIniFileLC() with a version that calls CEikApplication’s OpenIniFileLC(), such as:

CDictionaryStore* CMyAppApplication::OpenIniFileLC(RFs& aFs) const
{
return CEikApplication::OpenIniFileLC(aFs);
}

As well as opening the application’s .ini file for exclusive read/write access – and pushing it to the cleanup stack – this function will create the .ini file if it does not exist, and will replace a corrupt file. The function is called by the application architecture, for example to record the last opened file, and can be called by your application code.

The .ini file is represented by an instance of CDictionaryFile- Store, which derives from the CDictionaryStore base class. These classes are slightly misleadingly named since they have no connection with stream dictionaries. Also, since they do not derive from CStream- Store, they do not represent stream stores. Despite this, there are similarities of usage: the dictionary store contains streams associated with UIDs, and you read and write the streams by means of RDictionaryReadStream and RDictionaryWriteStream classes, in the same way as you would with a stream store.

However, a significant difference is that a dictionary store never contains more than a simple list of streams, unlike the complex network that is possible in a stream store. Furthermore, you use UIDs to access the streams directly, rather than via a stream dictionary.

//Write into .ini File
void WriteToIniFileL(RFs& aFs)
{
CDictionaryStore* iniFile = Application()->OpenIniFileLC(aFs);
RDictionaryWriteStream stream;
stream.AssignLC(*iniFile, TUid::Uid(0x101ffac5)); // direct access by
// UID
TUint16 i = 0x3456;
stream << i;
stream.CommitL();
iniFile->CommitL();
CleanupStack::PopAndDestroy(2); // stream and iniFile
}
 
//Read from .ini File
void ReadIniFileL(RFs& aFs)
{
CDictionaryStore* iniFile = Application()->OpenIniFileLC(aFs);
RDictionaryReadStream readStream;
readStream.OpenLC(*iniFile, TUid::Uid(0x101ffac5)); // direct access
// by UID
TInt16 i;
readStream >> i;
CleanupStack::PopAndDestroy(2); // readStream and iniFile
}

Other Related Links

Saving settings with Dictionary store

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditFurlTechnocratiMagnoliaTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZdescriptionQSxEa0E20WikiE20javaE20symbianE5fosE20s60E20maemoE20cE2bE2bE20WikiE20HomeE20WikiE20HelpE20OverviewE20GlossaryE20CreateE20PageE20ProposeE20anE20ArticleE20SpotlightE20TopicE20E2dE20WE52TE20WidgetsE20ProgrammingE20E4canguageE20E2dE20SymbianE20CE2bE2bE20E2dE20OpenE20CE2fCE2bE2bE20E2dE20JavaE20E2dE20FlashE20E4citeE20E2dE20PythonE20WebE20TechnologiesE20E2dE20WE52TE20WidgetsE20E2dE20WidSetsE20ToolsE20andE20SE44KE20CodeE20E45E78amplesE20KnowledgeE20BaseE20TechnologyE20AreasE20SoftwareE20PlatformsE20E44evelopmentE20ProcessE20E3fE3fWikiE20ChineseE20E3fE3fE3fWikiE20JapaneseE20PortugueseE2fBrazilianE20E52ussianE20WhatE20linksE20hereE20UploadE20fileE20SpecialE20pagesE20PrintableE20versionE44ownloadE20asE20PE44FE20GoE20ToE20E2eE2eE2eX qdcZidentifierQSxhttpE3aE2fE2fwikiE2eforumE2enokiaE2ecomE2findeE78E2ephpE2fMMPE5ffileX qdcZpublisherQUxhttpE3aE2fE2fswE2enokiaE2ecomE2fidE2fc764fd1cE2d8b06E2d499aE2d9a6aE2d17c3903d5a65E2fforumE5fnokiaE5fcrawlerE5fagentX qdcZtitleQSxMMPE20fileE20E2dE20ForumE20NokiaE20WikiX qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfnTypeZCommunityContentQ qdcZtypeQUqfnTypeZE52esourceQ qdcZtypeQUqfnTypeZWebpageQ qdcZtypeQUqfnTypeZWikiContentQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qrssZdescriptionQSxEa0E20WikiE20javaE20symbianE5fosE20s60E20maemoE20cE2bE2bE20WikiE20HomeE20WikiE20HelpE20OverviewE20GlossaryE20CreateE20PageE20ProposeE20anE20ArticleE20SpotlightE20TopicE20E2dE20WE52TE20WidgetsE20ProgrammingE20E4canguageE20E2dE20SymbianE20CE2bE2bE20E2dE20OpenE20CE2fCE2bE2bE20E2dE20JavaE20E2dE20FlashE20E4citeE20E2dE20PythonE20WebE20TechnologiesE20E2dE20WE52TE20WidgetsE20E2dE20WidSetsE20ToolsE20andE20SE44KE20CodeE20E45E78amplesE20KnowledgeE20BaseE20TechnologyE20AreasE20SoftwareE20PlatformsE20E44evelopmentE20ProcessE20E3fE3fWikiE20ChineseE20E3fE3fE3fWikiE20JapaneseE20PortugueseE2fBrazilianE20E52ussianE20WhatE20linksE20hereE20UploadE20fileE20SpecialE20pagesE20PrintableE20versionE44ownloadE20asE20PE44FE20GoE20ToE20E2eE2eE2eX qfnZdistributionQUxhttpE3aE2fE2fwikiE2eforumE2enokiaE2ecomE2fX qfnZtypeQUqfnTypeZCommunityContentQ qfnZtypeQUqfnTypeZE52esourceQ qfnZtypeQUqfnTypeZWebpageQ qfnZtypeQUqfnTypeZWikiContentQ qfnZupdatedQDx2008E2d10E2d02X qfnZuserE5ftagQSxfileX qfnZuserE5ftagQSxlibpathX qfnZuserE5ftagQSxmmpX qfnZuserE5ftagQSxresourceX qmarsZdescriptionQSxEa0E20WikiE20javaE20symbianE5fosE20s60E20maemoE20cE2bE2bE20WikiE20HomeE20WikiE20HelpE20OverviewE20GlossaryE20CreateE20PageE20ProposeE20anE20ArticleE20SpotlightE20TopicE20E2dE20WE52TE20WidgetsE20ProgrammingE20E4canguageE20E2dE20SymbianE20CE2bE2bE20E2dE20OpenE20CE2fCE2bE2bE20E2dE20JavaE20E2dE20FlashE20E4citeE20E2dE20PythonE20WebE20TechnologiesE20E2dE20WE52TE20WidgetsE20E2dE20WidSetsE20ToolsE20andE20SE44KE20CodeE20E45E78amplesE20KnowledgeE20BaseE20TechnologyE20AreasE20SoftwareE20PlatformsE20E44evelopmentE20ProcessE20E3fE3fWikiE20ChineseE20E3fE3fE3fWikiE20JapaneseE20PortugueseE2fBrazilianE20E52ussianE20WhatE20linksE20hereE20UploadE20fileE20SpecialE20pagesE20PrintableE20versionE44ownloadE20asE20PE44FE20GoE20ToE20E2eE2eE2eX qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfnTypeZCommunityContentQ qrdfZtypeQUqfnTypeZE52esourceQ qrdfZtypeQUqfnTypeZWebpageQ qrdfZtypeQUqfnTypeZWikiContentQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ