PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV Mobile 2024 → Copying Sqlite database from PC to Android phone
Copying Sqlite database from PC to Android phone
Débuté par George, 10 mai 2011 19:42 - 4 réponses
Posté le 10 mai 2011 - 19:42
By following the instructions, found in Windev help system, I am am trying to copy a SQLite database from my PC to my Android phone:
1. I am registering the file to be copied: MYDATABASE.db by using "Directory Automatic" in "Integration Files" screen during the "Generate Android Application Process".
2. I am using the fExtractResource("MYDATABASE.db", "/sdcard/database.db")
In this case fExtractResource() function return FALSE.

If I select "Directory Raw" in "Integration Files"; the fExtractResource() return TRUE but the file MYDATABASE.DB is not read correctly. An error message indicates that the file is encrypted or not is a SQLlite database file.

I did other testing trying to copy a simple CSV file from my PC to my Android phone but I got the same errors.
The only one that fExtractResource() return TRUE is when I select "Directory Raw" in "Integration Files" screen. However when I read the information in that file, instead of a string with the original information I am getting the following string: <?xml version = "1.0" encoding = "UTF-8"?>

I appreciate your help regarding this issue.
If any of you have a sample will be helpful.

Regards

George
Membre enregistré
19 messages
Posté le 17 mai 2011 - 02:51
I was able to find out where the problem was:
I was trying to read a 20 mega file with over 16,000 records, (not problem at all with WinDev Simulator), but I realized that the Android system cannot read a CSV or SQLite file of that size.
I did a test with just 600 records (55K) and both files have been read by my Android Phone Galaxy S.

George
Posté le 18 mai 2011 - 13:39
I had the same problem ....

Here is the response from PCSOFT support (in french) : for db bigger than 1Mo, the compression/decompression is not working well .... they are working to solve the problem.

=====
En fonction du périphérique des cas d'échec de compression / décompression de fichiers ont pu être identifiés, et sont en cours de résolution.

Un palliatif immédiat, peut être de placer le .db dans l'application, en empêchant sa compression. Pour parvenir à ce résultat, il faut modifier l'extension du fichier contenant les données. En effet, tous les fichiers de plus de 1 Mo à placer dans l'application apk sont compressés, sauf ceux ayant l'extension :
".jpg", ".jpeg", ".png", ".gif", ".wav", ".mp2", ".mp3", ".ogg", ".aac", ".mpg", ".mpeg", ".mid", ".midi", ".smf", ".jet", ".rtttl", ".imy", ".xmf", ".mp4", ".m4a", ".m4v", ".3gp", ".3gpp", ".3g2", ".3gpp2", ".amr", ".awb", ".wma", ".wmv"

je vous conseille donc de renouveler le test en effectuant les opérations suivantes :
- renommer sur le PC le .db en .mp3 par exemple avant de créer l'application android
- créer l'application en ajoutant le fichier .mp3 des données,
- après l'appel de fExtraitChemin, renommer le .mp3 extrait en .db à l'aide de la fonction fRenomme.
============
Membre enregistré
19 messages
Posté le 18 mai 2011 - 18:41
Deal avec l'extension mp3, mais ne fonctionne pas.

Cependant, avec l'extension “. Jpg “ la fonction suivante fonctionne parfaitement.
fExtractResource("my_table.jpg", "/sdcard/Android/data/com.mycompany.srt_lite/databases/sql_srt.db")

Je pouvais lire des fichiers de plus de 20 méga pas de problème.

Cordialement,

George
Posté le 10 août 2011 - 10:09
Hi George,

Thank You for this posts, You helped me a lot. This trick with renaming DB into JPG, then Extract JPG into DB - works. Just one addition, maybe will help somebody: Root dir for external memory card could be:
"/sdcard/Android/data/..."
but also could be:
"/mnt/sdcard/Android/data/..."

Regards,
Drazen