On Jun 30, 7:57 pm, David Janes <davidja
...@gmail.com> wrote:
> Yeah, I know what group this is but a few of you have programmed for the BB
> ;-)
Hey, some of us are trying to forget that period of our lives. ;)
> I'm trying to make a BlackBerry app & I want to include a lot of data with
> it that will be on "disk" or whatever the hell it is a BB has. For example,
> I need to read a JSON file shipped with the app.
If you're shipping it with the app, then it should be in the app's jar
file. (It looks like there's also a file system of some sort, but I
don't think that'll be populated when you install the app, so you
should just stuff it in the jar file.
> Do you have any idea:
> - how it should be properly added to Eclipse?
In theory, you can just drag and drop it into the source folder.
> - how it can be read
Here's what I use. It's the standard/best practice, so I don't think
it's covered under any NDA/license.
[...]
JSONObject root;
public SampleApplication()
{
InputStream stream = getClass().getResourceAsStream( "/res/
samplefeed.json" );
int length = 10240;
byte[] bArray = new byte[length];
StringBuffer data = new StringBuffer();
while ( (length = stream.read( bArray )) != -1 )
{
data.append( new String( bArray, "UTF-8" ) );
}
root = new JSONObject( data.toString() );
}
[...]
See also http://www.blackberry.com/developers/docs/4.5.0api/java/lang/Class.ht...
> I've tried using Connector, but it's not evident after some experimentation
> what file://... URL I should be using.
It looks like the Connector stuff is for files you store on an CF
card.
http://www.blackberry.com/developers/docs/4.5.0api/javax/microedition...
suggests that you should be using "file:///CFCard/newfile.txt" (Note
the empty hostname between the second and third slashes. :P )
> I don't even really know what the correct terminology for talking about this is.
That all seemed understandable to me.
Later,
Blake.