How to use apk expansion files in Basic4android?

paragkini

Member
Licensed User
Longtime User
Hi,
How can we use apk expansion files in b4a? I have an application with few videos and pdf files but I dont want them to be copied by the user just like that. I believe I can pack them all in expansion file and start pointing and using them within expansion file. Is there any way to do this is B4A?

regards,
Parag Kini

:sign0163:
 

mc73

Well-Known Member
Licensed User
Longtime User
Aren't you placing your files in the files' tab on the right side of b4a window? Or perhaps you mean something else that I don't understand...
 
Upvote 0

margret

Well-Known Member
Licensed User
Longtime User
Google Play lets you have two, 2gig additional resource files to store extras like .mp4, ogg files, images, etc. This only works from Google Play and no other store like Amazon. This could be useful for some but your data is not protected and this requires a SD Card. I do not think this can be fully used in b4a at this time. The code below is needed to set the media playable without extracting it to another location. You could use these files now just to store movies, audio and graphics but you would have to extract them before use and they can not be extracted to the same directory that holds these resource files. Also, after you've extracted the files you needed, you can not delete these files as it will mess up Google Play and it will try to always re-download these files. So using them now would use a ton of storage space on the device. Maybe one of the Lib guys will produce a library if enough people start trying to use this or may know another way.

B4X:
public void setDataSource (FileDescriptor fd, long offset, long length) 
Since: API Level 1 Sets the data source (FileDescriptor) to use. 
The FileDescriptor must be seekable (N.B. a LocalSocket is not seekable). 
It is the caller's responsibility to close the file descriptor. 
It is safe to do so as soon as this call returns.

Parameters
fd  the FileDescriptor for the file you want to play 
offset  the offset into the file where the data to be played starts, in bytes 
length  the length in bytes of the data to be played 

Throws
IllegalStateException  if it is called in an invalid state  
IOException   
IllegalArgumentException
 
Last edited:
Upvote 0

paragkini

Member
Licensed User
Longtime User
Thanks... but....

Thanks Margret. However, I didnt understand how to use it in b4a
B4X:
public void setDataSource
.

@mc73, My problem is I keep updating the files and they are a lot. So cant release the apk alway. Just changing minor version would make it download expansion file and I can start using.
 
Upvote 0
Top