Tornado Touch Support 0011

Large DB file

Using TL02 on Samsung Galaxy S:

  • If a large DB file is created (i.e. 4-6 MB) - then the file cannot be used by the TL02 (Street Map London) application. If the 'Gazetteer' option is slected from the 'Setting' view - then when a query is entered, the phone buzzes and displays following message:
Sorry!
The application Street Map London (process com.dhp11.tl02) has stopped unexpectedly. Please try again.

When file is 'cut-down' to 1.5 MB worked OK

2011-05-24

This was due to a missing write permission in the AndroidManifest? file.

   uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" 

The asset files like the gazeetter, map images, etc were not being copied because the app didn't have permission. You don't need this permission on earlier version of the OS. When this was put in and recompiled it copied the files fine and everything worked.

2011-05-25

The above fix worked for the Samsung Galaxy S. For the Dell Streak it did not. After some debugging and google searching I found out (then remembered) that you can not have asset files over 1MB in an APK, if you do they default to zero bytes which is why it was causing the error because the DB being copied was zero bytes. I will need to beable to concatenate a series of smaller db files to create the larger one on the device.

I have added code to TL01 and TL02 to copy the database in chunks. This assumes to have split your larger database into smaller (under 1MB) files. The code looks for a text file in the assets directory called db.txt which contains the list of files to join. The split database files are not copied into a folder called \db\ under \assets I have also write a small C program to split a file into smaller files. Here is the code:

#include 
#include 
#include 
#include 

void splitfile 
(
   char *pcIn, 
   int   iBytes
);


void main 
(
   int   iArgs    ,
   char *apsArgs[]
)
{
   char *pcFile = NULL;
   int   iKB    = 0;

   if (iArgs == 3)
   {
      pcFile = apsArgs[1];
      iKB    = atoi (apsArgs[2]);

      printf ("%s KB=%d\n", pcFile, iKB);
      splitfile (pcFile, iKB);
   }

   return;
}


void splitfile 
(
   char *pcIn, 
   int   iKB
)
{
   char  sOutFile [255+1];

   FILE *pFi    = NULL;
   FILE *pFo    = NULL;
   int   iCh    = 0;
   int   i      = 0;
   int   iChars = 0;
   int   iBytes = 0;
   int   bDone  = 0;

   iBytes = iKB * 1024;

   pFi = fopen (pcIn, "rb");

   while (!bDone)
   {
      sprintf (sOutFile, "%s.%d", pcIn, i++);
      printf ("%s\n", sOutFile);

      pFo = fopen (sOutFile, "wb");

      while (EOF != (iCh = fgetc (pFi)))
      {
         fputc (iCh, pFo);
         iChars++;

         if (iChars == iBytes)
            break;
      }

      if (iCh == EOF)
         bDone = 1;

      iChars = 0;
      fclose (pFo);
   }

   fclose (pFi);
}

The usage:

split.exe  C:\source\tl01.src\assets\db\street.db 512 

This will split the street.db into smaller files each a maximum of 512kb You then need to create a db.txt file and list the files created.

street.db.0
street.db.1
street.db.2
street.db.3
street.db.4
street.db.5
street.db.6
street.db.7
street.db.8
street.db.9
Topic attachments
I Attachment Action Size Date Who Comment
split.exeexe split.exe manage 20.6 K 25 May 2011 - 11:51 Main.dg Command line program to split larger files.
Topic revision: r3 - 25 May 2011 - 12:21:55 - Main.dg
 

This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback