A Couple or Three Distribution Questions

mjtaryan

Active Member
Licensed User
Longtime User
1. Where will I find instructions on how to create a distribution package that puts the non-system data files (text, images, etc.) in a particular directory/subdirectory on the SD card?

2. How do I generate encrypted unlock/license keys (are there good packages for doig this or does B4a have its own)?

3. Is it possible to search the user's device to find a particular app and, if the user doesn't have it, offer him/her a link to that app on Android Market? How?

Thanks.
 

Kim Rowden

Member
Licensed User
Longtime User
Erel,
On item 1 - adding the files to the Files tab... where is this "Files tab"?

I can see that any images I add via the designer get added to the DirAssets folder.... but I can't see any other option to add files (via the Designer or the IDE).

Thanks,
-Kim

UPDATE: Ooops - I found it... extreme bottom right of the IDE. Sorry!
 
Last edited:
Upvote 0

mjtaryan

Active Member
Licensed User
Longtime User
Kim,

The code editor (not the Designer) has two panels; the one on the left shows the code, the one on the right shows the resources. At the botton of the resources panel, near the Windows status bar, are a series of 4 tabs. These are named Modules, Files, Logs and Libs,

However, Erel, the tutorial doesn't meet my requirements. Perhaps I wasn't sufficiently clear. I want to be able to create and name my own directories and specify which files goes into each of these directories. Thus, I want to be able to have a structure that looks like mnt/sd card/android/pkg-name/data <created by me>/<the additional directories I need or want such as audio, db, docs, help, icons, images, text, video and so forth>/<files to be stored in their respective folders>. I've been doing this for years and, unless absolutely necessary, see no reason to change the practice. So, can I do this and, if so, how?

Additionally, when I mentioned license key, I wasn't talking about a key that I would need to generate as part of signing the app for submisison to Android Market, but rather a key the user would need to enter to unlock the full and unrestricted version of the package. Or is B4a using the signing key for this function as well?
 
Last edited:
Upvote 0

agraham

Expert
Licensed User
Longtime User
Not via the Files tab but you seem to be able to if you add them yourself in the Files folder. Robert does this in his Planisphere app to keep his images separate. The individual folders get packed into the apk and you can access them by something like.

LoadBitmap(File.DirAssets,"afolder/afile.png")

or

File.OpenInput(File.DirAssets, ,"afolder/afile.txt")
 
Upvote 0

mjtaryan

Active Member
Licensed User
Longtime User
So, I gather from what you both have written that I can have subfolders, but at this point they need to be subordinate to the Files folder. My question now is how do I specify that thee Files folder and all of its contents be stored on the SD Card rather than the default DirInternal? I tried to look at the only tutorial I could find (the one about using the virtual SD card), but the link for downloading the tutorial didn't work for me.
 
Upvote 0

nfordbscndrd

Well-Known Member
Licensed User
Longtime User
My question now is how do I specify that thee Files folder and all of its contents be stored on the SD Card rather than the default DirInternal?

In Activity_Create, you can copy the files from DirInternal to /sdcard/, but see this post. The code for copying files is:

File.Copy(File.DirAssets, "myfile.xyz", "/sdcard", "myfile.xyz")

but I haven't tried copying a folder, but instead of "myfile.xyz", I believe that you have to use Combine("myfolder", "myfile.xyz").

Since the user can remove the sdcard, you should check each time you want to access the files to make sure they are still there.

For example: If File.Exists("/sdcard", Combine("mydir", "myfile.xyz")) Then ...

Also note that some devices do not have SD drives, in which case they use part of internal storage as "sdcard".

I wouldn't swear to the accuracy of any of the above code (written on the fly), but if it's wrong, I'm sure someone will correct me.
 
Last edited:
Upvote 0

corwin42

Expert
Licensed User
Longtime User
Not via the Files tab but you seem to be able to if you add them yourself in the Files folder. Robert does this in his Planisphere app to keep his images separate. The individual folders get packed into the apk and you can access them by something like.

LoadBitmap(File.DirAssets,"afolder/afile.png")

or

File.OpenInput(File.DirAssets, ,"afolder/afile.txt")

Sorry to pull up this thread up again.

This seems to work but it seems that File.Exists does not work with this method. I tried to use

File.Exists(File.DirAssets, "icons/na.png") and it returns false but I can load the file with

LoadBitmap(File.DirAssets, "icons/na.png")
 
Upvote 0
Top