12-13-2010 07:56 PM
Is the userDirectory available?
I know applicationStorageDirectory is.
If userDirectory is available, what would its path be?
12-13-2010 08:19 PM
hey dachflach,
according to File.userDirectory.nativePath the userDirectory refers to the /root directory. I dont know how that will hold up later down the road because it seems odd like an odd place to map it to. but for now thats where it stands. Also note when you perform the documentsDirectory or desktopDirectory it builds off of the /root directory. I also can confirm you can create and copy files into that directory in the simulator. But again i dont know how it will hold up in the real playbook. Hope that helps!
12-13-2010 08:50 PM
Thanks for the heads up on the potential problems down the road.
Isn't the applicationStorageDirectory also under the users folder structure as well.. ( appData/roaming on windows)?
Can anyone from RIM expand on this? ( no offense intended JRab, just looking for more info ).
Are the userDirectory, documentsDirectory and desktopDirectory considered unsafe?
Do they have a future?
My implementation is as such:
I create local Databases that hold users of an app and their details. These Users can then be added to a remote database to combine with other Users on other tablets.
Now, I can handle that from a DB stored in applicationStorageDirectory but I fear for loss of data upon reinstallation of the app and I believe the applicationStorageDirectory is harder for a User to navigate to.
I also store images and various other files with the AppDirectory I create within the userDirectory. This location is easy to find on desktop OS so I am hoping it is as well for this OS.
Any more elaboration welcome.
12-14-2010 07:43 AM
12-14-2010 11:34 AM
I was hoping to be able to transfer files from a directory on the PB to a USB connected desktop or laptop.
Navigating ( from the desktop ) to the userDirectory would be easier than to the applicationStorageDirectory.
The files could be anything from text files to images to wav files.
A confirmation on using userDirectory files now and in the future would still be nice.
Personally, I do not need to have multiple Users.. so is Root such a bad thing?
12-14-2010 11:47 AM
12-14-2010 12:01 PM
Probably already know this, but in case for newbies. Dont hardcode path names. Leverage the File standard directories every time. If the implementation for one changes from /root, then nothing in your application will change. If they do change where physically a directory exists, the OS upgrade will certainly move relatvent files.
As to USB connection to the PB from a desktop to transfer files. Nothing has been said that currently exists. Assume that it would since BB does that will cell phones, but currently nothing has been officially mentioned about interoperability between PB and desktop yet (obviously if some knows more, please correct me).
12-14-2010 12:40 PM
"just make some sort of global variable that you point to userDirectory for now"
Isn't userDirectory that itself? Or do you mean bring in a remote path name or hard code one in the app ( read previous post ).
What I planned to do was use userDirectory as the root for the app folder where the files and other folders would be created inside of. Leveraging the FILE standard directories as mentioned.
"If they do change where physically a directory exists, the OS upgrade will certainly move relatvent files."
That statement seems promising. Any files created before an OS change would be moved to the appropriate new location. Is there any reason to believe this would not be so?
Another reason to store files in userDirectory ( or documentsDirectory, desktopDirectory ) is so that files can be shared across applications. For example, if a suite of tools ( each an individual app ) have reason to utilize files created from other apps, this can be done by storing them in those folders. And from what I am gathering, might not be achievable by using the applicationStorgaeDirectory.
Any thoughts on that?
Dach
12-14-2010 01:01 PM - edited 12-14-2010 01:25 PM
DachFlach wrote:
What I meant was, instead of possibly sprinkling File.userDirectory around your code, you could define something like a "myAppDirectory = File.userDirectory" at startup in one place, and use myAppDirectory everywhere else. Then at a later time, if improved docs say "userDirectory will be null on PB, use applicationStorageDirectory" you have only one change to make. The thing is, there are probably hundreds of RIM and QNX devs working very hard trying to resolve all these things before launch, and none of us can say for sure what will happen between now and then with all these little details. Be agile, plan for numerous small changes."just make some sort of global variable that you point to userDirectory for now"
Isn't userDirectory that itself? Or do you mean bring in a remote path name or hard code one in the app ( read previous post ).
DachFlach wrote:
Another reason to store files in userDirectory ( or documentsDirectory, desktopDirectory ) is so that files can be shared across applications. For example, if a suite of tools ( each an individual app ) have reason to utilize files created from other apps, this can be done by storing them in those folders. And from what I am gathering, might not be achievable by using the applicationStorgaeDirectory.
As your final paragraph, I agree that's the purpose of userDirectory. Your description of the data involved, however, seemed to fit more closely with the purpose of applicationStorageDirectory as it sounded like the application's data rather than the user's data, even if it involves data about the user. You know best how it will be used, so if you understand the distinction between those two things, I'm sure you'll pick the best thing based on what we know now. And do what I suggest above and you won't be slowed down if the final setup is not what you expected.
(Edited to better show who actually wrote what. Sorry about that.)
12-14-2010 01:16 PM
I read "hard coded" to something like "/root/myfile.db" (bad). Your suggestion of referencing user data from a File native path sounds good.
File.applicationStorageDirectory is typically for application specific things that the user would not interact or even know about like preferences. If an application updates, it may replace/update files in that location upon first run, so keeping users out of this directory would be important.
If you're storing data with SQLite, it is a good practice to maintain a version of the file as it relates to your schema. I've added "info" table that maintains 1 record of information about the schema, so if the shema changes, then your application has the knowledge to update older versions of the file.