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.
Install data files from apk
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Install data files from apk
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
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
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Install data files from apk
I just tested this code from FiveTouch:
But not sure if one of the returned values is the one that we are looking for
Code: Select all
#include "FiveTouch.ch"
function Main()
local n
for n = 1 to 20
MsgInfo( QStandardPaths():StandardLocations( n ):Value( 0 ) )
next
return nil
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Install data files from apk
Pritpal has published some code to do it:
https://groups.google.com/forum/#!topic ... E60mMvHXdc
https://groups.google.com/forum/#!topic ... E60mMvHXdc
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.
Re: Install data files from apk
I saw that. I will be working on it this weekend.
Thanks.
Thanks.
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Install data files from apk
Gale,
Very good,
I look forward to know your results, thanks!
Very good,
I look forward to know your results, thanks!
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Install data files from apk
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.
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.