ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Standard functions / Windows functions / Miscellaneous WINDEV functions
  • Example for the InAndroidMode function
InAndroidMode (Example)
Example for the InAndroidMode function
This example allows you to use an SQLite database on Android with access to the database from a PC when the device connects via USB.
The database will be stored on the SD Card of the device.
// CntSQLiteDatabase is the name of the connection defined in the analysis
 
// Directories on the SD Card for accessing the SQLite database
sDataDirectory is string = "data_wm_androidsqlitedatabasesharepc"
// Name of the SQLite database
sNameSQLiteDatabase is string = "wm_sqlitedatabase.db"
// Unit corresponding to the SD Card of the Android device (from a Windows application)
// To be asked to the user and to be stored in a parameter file
sUnitSDCardFromPC is string = "e:"
 
// In any case, the database is in SQLite format (only format supported by Android)
CntSQLiteDatabase.Provider = hNativeAccessSQLite
 
// Execution on the Android device?
IF InAndroidMode() = True THEN
// yes
// WINDEV Mobile simulator?
IF InSimulatorMode() = True THEN
// Database in the Exe directory of the project
CntSQLiteDatabase.Source = fExeDir() + ["\"] + sNameSQLiteDatabase
ELSE
// Execution on the Android device or on the emulator
// (there is the storage card if it is available)
IF SysStatusStorageCard() = sysCardAvailable THEN
// Localizes the database on the SD Card, in relation to the mobile
CntSQLiteDatabase.Source = SysDirStorageCard() + ["/"] + ...
sDataDirectory + ["/"] + sNameSQLiteDatabase
ELSE
// No storage card
Error("No storage card is available in write mode on this device")
EndProgram()
END
END
ELSE
// Execution on a PC?
IF InPocketMode() = True _OR_ InWindowsPhoneEmulatorMode() = True THEN
Error("Access to the database not intended on this runtime platform")
EndProgram()
ELSE
// IF SysWindowsVersion() IN
// ("98","NT 3.5","NT 4", "NT 5","ME","2003S","2008S","VISTA","7") THEN
// localizes the database on the SD Card, in relation to the PC
CntSQLiteDatabase.Source = sUnitSDCardFromPC + ["\"] + ...
sDataDirectory + ["\"] + sNameSQLiteDatabase
END
END
 
// Open the connection
IF HOpenConnection(CntSQLiteDatabase) = False THEN
Error("Failure connecting to the SQLite Android database", HErrorInfo())
EndProgram()
END
 
HCreationIfNotFound("*")
 
Info("Connection to the database established")
Minimum version required
  • Version 16
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 05/26/2022

Send a report | Local help