ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / WLanguage functions / Standard functions / External file functions
  • Generation wizard
  • Special case: database extraction
  • Special case: ".WDD" file (analysis description)
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Extracts a resource from the application into a physical device location.
Remarks:
  • AndroidAndroid Widget iPhone/iPadIOS WidgetMac Catalyst The resource to extract must have been included in the generated application by the generation wizard (see Notes).
  • WindowsLinux In WINDEV applications or WEBDEV websites, the resource to extract must be:
    • in the "Other" category of the Project explorer pane,
    • in the main library of the application (WDL file).
  • AndroidAndroid Widget This function can be used in the Android simulator.
Warning: To prevent source code piracy, WINDEV, WEBDEV and WINDEV Mobile elements (states, windows, etc.) cannot be extracted at runtime.
Example
Android
// Lit le contenu du fichier texte readme.txt inclus dans les ressources de l'application
IF fExtractResource("readme.txt", "/sdcard/extraction.txt") = True THEN
	SAI_Texte = fLoadText("/sdcard/extraction.txt") 
END
Android
// Permet de localiser précisément ses données HFSQL sur le Smartphone Android
sCheminDonnées is string = SysDirStorageCard() + fSep() + "Test clients"  + fSep()
IF NOT fDirectoryExist(sCheminDonnées) THEN fMakeDir(sCheminDonnées)
fExtractResource("Produit.fic", sCheminDonnées + "Produit.fic")
fExtractResource("Produit.ndx", sCheminDonnées + "Produit.ndx")
fExtractResource("Produit.mmo", sCheminDonnées + "Produit.mmo")
IF NOT HChangeDir(Produit, sCheminDonnées) THEN
	Error(HErrorInfo())
END
Android
// Extrait toutes les images au format PNG
fExtractResource("*.png", CompleteDir(SysDirStorageCard()) + "images")
Syntax
<Result> = fExtractResource(<Resource name> [, <Destination>])
<Result>: Boolean
  • True if the resource was extracted,
  • False otherwise. If an error occurs, the ErrorOccurred variable is set to True. To get more details on the error, use ErrorInfo.
<Resource name>: Character string
Name of resource to extract (file name with its extension).
AndroidAndroid Widget iPhone/iPadIOS WidgetMac Catalyst Wildcard characters (* and?) are allowed. This allows you to extract several resources in a single call. In this case, the <Destination> parameter must correspond to a directory (that exists or not).
WindowsLinux The resource to extract must be found in the main application library (WDL file). The library must have not been loaded by LoadWDL.
<Destination>: Optional character string
AndroidAndroid Widget Full or relative path of destination file. This path can be relative to the current directory (returned by fCurrentDir). This parameter is case-sensitive.
If the directory exists, the resource is directly extracted into this directory.
The directory is created if it does not exist.
If this parameter is not specified or is an empty string (""), the resource will be extracted into the current application directory in a file named like the resource.
The destination file will be overwritten if it already exists before the extraction.
Reminder: In Android, the file system is read-only on the device and on the emulator. An application can only write to its installation directory or one of its subdirectories, as well as to the external memory (SDCard).
iPhone/iPadIOS WidgetMac Catalyst Full path of destination file. This parameter is case-sensitive.
If the directory exists, the resource is directly extracted into this directory.
The directory is created if it does not exist.
If this parameter is not specified or is an empty string (""), the resource will be extracted into the "Documents" application directory in a file named like the resource.
The destination file will be overwritten if it already exists before the extraction.
WindowsLinux Full path of destination file.
If the directory exists, the resource is directly extracted into this directory.
The directory is created if it does not exist.
If this parameter is not specified or is an empty string (""), the resource will be extracted into the application data directory (returned by fDataDir) in a file named like the resource.
The destination file will be overwritten if it already exists before the extraction.
Remarks
AndroidAndroid Widget iPhone/iPadIOS WidgetMac Catalyst

Generation wizard

The Android or iPhone/iPad application generation wizard lets you specify whether files and libraries are to be integrated into the application.
In an Android application, you have the ability to include:
  • specific resources.
  • specific Java archives.
Then, these files can be:
  • used directly (files to be read, for example: sound files, image files, etc.).
  • extracted with fExtractResource (e.g., files that will be modified by the application)
If an image is included in the application, it can be directly assigned to a control by specifying its name. For example:
IMG_Image = image1
AndroidAndroid Widget iPhone/iPadIOS WidgetMac Catalyst You have the ability to list the files included in the application with fListResource.
For more details, see:
AndroidAndroid Widget

Special case: database extraction

If the file to extract is an SQLite database, use fDataDir to extract it into the data directory of the application ("databases" directory).

Example:
fExtractResource(<Database vame>.db, CompleteDir(fDataDir()) + <Database name>.db)
To connect to this database, all you have to do is specify <Database name>.db as source for the SQLite connection. For more details, see Android application: Using a database.

Special case: ".WDD" file (analysis description)

An analysis description (".WDD" file) integrated to the library of an application cannot be extracted.
To extract a file from a library that cannot be extracted by fExtractResource, you can use an HFSQL data file integrated in the library.
Component: wd300vm.dll
Minimum version required
  • Version 16
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 03/27/2025

Send a report | Local help