FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveTouch Install data files from apk
Posts: 663
Joined: Mon Dec 05, 2005 11:22 PM
Install data files from apk
Posted: Thu Jul 09, 2015 03:17 PM

After quite a bit of searching it seems there is no easy way to install data that have been included in apk.
It is recommended to use assets in apk and then the installed program would use java functions getAssets().open("path/file.ext") or getResources() to access the data stream in apk
I can't find getAssets() or getResources() in Harbour or QT.
I would rather not have to download separate Data, PRG, and other files during installation.

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Install data files from apk
Posted: Thu Jul 09, 2015 08:31 PM

Gale,

I have just emailed Priptpal Bedi (HbQT developer) to know if GetAssets() is supported in HbQT.

I just realized that an APK is a ZIP file, so if we could get the path of the APK then we could extract the
files from the APK itself using Harbour :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Install data files from apk
Posted: Thu Jul 09, 2015 08:48 PM
I just tested this code from FiveTouch:

Code (fw): Select all Collapse
#include "FiveTouch.ch"
      
function Main()
      
   local n

   for n = 1 to 20
      MsgInfo( QStandardPaths():StandardLocations( n ):Value( 0 ) )
   next

return nil


But not sure if one of the returned values is the one that we are looking for
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Install data files from apk
Posted: Thu Jul 09, 2015 08:55 PM
Pritpal has published some code to do it:

https://groups.google.com/forum/#!topic/qtcontribs/AE60mMvHXdc

FUNCTION __testRDD()
LOCAL dir_, cQrcFile, cPath

cPath := QStandardPaths():writableLocation( 9 ) // 9 == the only one which works, tested with 1.2.3 etc.

ft_mkDir( cPath + "/" + "accmix" ) // it will fail if "accmix" already exists

IF ! hb_fileExists( cPath + "/" + "accmix" + "/" + "ACCFBASE.MXD" )
cQrcFile := hb_base64Decode( __hbqtLoadResource( ":/tables/ACCFBASE.MXD" ) )
hb_MemoWrit( cPath + "/" + "accmix/ACCFBASE.MXD", x )
ENDIF
USE ( cPath + "/" + "accmix/ACCFBASE.MXD" ) VIA "DBFCDX"
dbGoTop()
hbqt_debug( FieldGet( 1 ) )
USE
dir_:= Directory( cPath + "/" + "accmix/*.*" )
hbqt_debug( cPath + "/" + "accmix/*.*" )
AEval( dir_, {|e_| hbqt_debug( hb_ValToExp( e_ ) + Chr( 10 ) ) } )

RETURN NIL



In the .qrc
========
<file>tables/ACCFBASE.MXD<file>

The binaries must be stored in .qrc hb_base64Encode()ed.


As Android is a Linux kernel, make sure that file/folder names are case-sensitive.

QStandardPaths():writableLocation( 9 ) gives a permanent place to
read/write whatever you want. So create a unique folder inside there
and organize the files in subfolders. This will also ensure that whenever
you ship another version of your app, the data is not lost.
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 663
Joined: Mon Dec 05, 2005 11:22 PM
Re: Install data files from apk
Posted: Thu Jul 09, 2015 09:28 PM

I saw that. I will be working on it this weekend.
Thanks.

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Install data files from apk
Posted: Fri Jul 10, 2015 11:23 AM

Gale,

Very good,

I look forward to know your results, thanks!

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Install data files from apk
Posted: Mon Apr 02, 2018 01:36 AM

In QT Creator project file:

COMMON_DATA.path = /assets
COMMON_DATA.files = $$PWD/FiveTouch.ch
COMMON_DATA.files += c:/harbour/include/hbclass.ch
COMMON_DATA.depends = FORCE
INSTALLS += COMMON_DATA

From our source:

QFile( "assets:/FiveTouch.ch" ):copy( "FiveTouch.ch" )
MsgInfo( File( "FiveTouch.ch" ) ) // shows .T.

regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion