Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
Developer
dnp
Posts: 28
Registered: ‎02-10-2012
My Device: playbook 4G/LTE
My Carrier: none
Accepted Solution

how to package data/* ($HOME/) files using the bar-descriptor.xml

hi, using native c/c++ sdk 1.0 with playbook simulator

i'd like to distribute with my app a couple datafiles that presumably should reside under the 'data/' ($HOME ?)

folder.

(i will be writing/updating them occasionally, so app/native/ is not appropriate i presume.)

 

in the bar-descriptor.xml i tried adding them as an 'asset'.

which plops them down right in app/native/*

 

so i edit the .bar XML to try to get them to land in data/

here's what i found:

    trying:  data/filename landed the file into app/native/data/filename

    trying:   ../../data/filename got error

    trying:   /data/filename got error (hoping leading slash was relative to sandbox)

i even on a lark tried:  $HOME/filename  which literally created app/native/$HOME folder! :smileyhappy:

so then it tried ${HOME} with the curlies. i got an error saying unable to resolve the path variable.

 

how do i get data files into the /data ($HOME) folder using the .bar packaging?

 

Please use plain text.
BlackBerry Development Advisor
elena_laskavaia
Posts: 417
Registered: ‎10-27-2010
My Device: PlayBook

Re: how to package data/* ($HOME/) files using the bar-descriptor.xml

You cannot package file in data, you copy your files on startup if they don't exists from your app/native/data for example

Please use plain text.
Developer
Developer
dnp
Posts: 28
Registered: ‎02-10-2012
My Device: playbook 4G/LTE
My Carrier: none

Re: how to package data/* ($HOME/) files using the bar-descriptor.xml

thank-you for the quick response!

 

i had considered having the app do an 'online update' at first install.

just never occured to me to have redundant copies of files locally...

 

so, apps have to do a  "self install" i guess. seems silly.

 

what if it was a large DB ? (it isn't in my case) but...

two copies of large datasets seems potentially a bit, um, inelegant.

 

Please use plain text.
Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: how to package data/* ($HOME/) files using the bar-descriptor.xml

Just some background on this.. When the app installs, the data folder won't even exist yet. Apps actually get unpacked into their own subfolder under /apps (i.e. a root-level folder), with the .bar contents being fully extracted there without modification. That folder is read-only to us.

When the app is first run (I'm 98% sure it's not before then) the app's sandbox area is created, under /accounts/1000/appdata/xxxx where the xxxx is the same name as the app's folder under /apps. (Note that the 1000 may be different for apps that are in the corporate data area, but let's ignore that.)

While it would be possible for the installer to identify parts of the app's data which should be transferred from the /apps subfolder to the /accounts/.../appdata/data subfolder, this is something that's not supported and possibly will never be.

I believe someone may have filed a feature request ticket for it once... you should check and, if you don't see one, create a new one asking for it and specifying the use case (which is a perfectly valid one, in my view).

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Please use plain text.
BlackBerry Development Advisor
smcveigh
Posts: 660
Registered: ‎11-29-2011
My Device: developer
My Carrier: other

Re: how to package data/* ($HOME/) files using the bar-descriptor.xml



what if it was a large DB ? (it isn't in my case) but...

two copies of large datasets seems potentially a bit, um, inelegant.

 


 

Couldn't you could access a read-only database in the app/native/data install location?  The problem with read-write assets, is that the app can be accessed by multiple users.  This is why there is an account-specicic /accounts/xxxx/appdata/ folder for such things.

Please use plain text.