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
New Developer
Slosh
Posts: 38
Registered: ‎01-24-2014
My Device: Q5

Web Service

Hello everyone,


I am a new developer. :Clap:

Before I begin sorry for the large number of questions. :Oops:
Well I did not put these questions only after many attempts to find Answers, But all my attempts failed. :No:


Q1: What is the best and fastest Xml or Json in blackberry?

 

Q2: How to make automatic update of the data when the application runs?

 

Q3: How to safe data in device then displayed again when run the application? ( Don't download the data again from Service ).

 

Q4: How to create pull to refresh data?

 

I have seen many examples, and it was the best application weatherguesser.
But use c ++

 

 

Please use plain text.
Developer
Zmey
Posts: 1,512
Registered: ‎12-18-2012
My Device: PlayBook, Z10, DAC

Re: Web Service

[ Edited ]

Hi! Welcome to the forums. Please create one thread per question, it will be easier to discuss them or search for them  later.

 

1)

For parsing XML and JSON there are XmlDataAccess and JsonDataAccess classes. If their functionality is sufficient, I'd try using them first. Performance is not critical unless you're working with really large data arrays. There are also classes for parsing XML in Qt (QXmlStreamReader etc), but I suggest trying BB ones first.

 

There is also higher level DataSource class which can load JSON or XML as well, even from remote source. It can be used from QML. It uses XmlDataAccess & JsonDataAccess internally.

 

2) For QML, there's DataSource class. After loading and parsing the data, populate the model. This page has some sample code:

http://developer.blackberry.com/native/reference/cascades/bb__data__datasource.html?f=datasource

Optionally, cache the data in a local database.

 

In C++ QNetworkAccessManager + QNetworkRequest classes can be used.

 

3) For saving user settings - QSettings. It stores them in a text file. Not recommended for large data sizes.

For saving large data arrays - sqlite database.

Big files such as images can be saved directly to disk.

All this caching has to be implemented manually.

 

Another option is downloading the data from webserver and saving the response "as is", then parsing it when the app starts.

 

If the data is large and delay during parsing is noticeable, the parsing can be done in a separate thread to not block the UI.

 

4) Pull to refresh: have you seen this thread?

http://supportforums.blackberry.com/t5/Native-Development/Pull-to-Refresh-example-on-GitHub/m-p/2157...

(I haven't tried using this control.)

 

QML is designed mostly for describing interfaces in declarative way. Most complex things in application logic are easier to do in C++ (or even impossible in QML with current set of libraries), so investing time into learning C++ is much recommended.

 

 


Andrey Fidrya, @zmeyc on twitter
Please use plain text.
Developer
BBSJdev
Posts: 6,116
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30

Re: Web Service

Welcome to the forums.

 

The problem with putting lots of questions (even if related) in the same thread is that it's a lot of effort needed to answer which will put some people off. Secondly if someone only knows say an answer to two of the questions they will feel uncomfortable not being able to answer the other two.

 

Thirdly it always ends up as an unwieldy long conversation with tens of posts, which some will then just look at the post count and think I can't be bothered to get in on that too much reading.

 

So for your benefit keep threads to one question only.

 

FYI I could answer all of these but I'm thinking I will get bogged down in the thread and not be able to do my own work, most of us will just want to fire off a quick, hopefully helpful,  response. So my advice keep to one question per thread and put a bit more meat on the bone with the background behind why you are asking the question as well.

 

 


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
Please use plain text.
Developer
BBSJdev
Posts: 6,116
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30

Re: Web Service

[ Edited ]

Not again. Are we linked mentally today or what. LOL! :smileyhappy:

 

I waited a while for you to answer and then we both post within minutes of each other!

 


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
Please use plain text.
Developer
simon_hain
Posts: 16,190
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Web Service

just as a sidenote: xml in a webservice usually means soap, and therefor not xmldataccess but QtSoap or another soap library.

if you have control over both backend and client you could use push to keep data up to date.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Retired
PBernhardt
Posts: 749
Registered: ‎12-16-2008
My Device: BlackBerry Z30

Re: Web Service

I like JSON, because XML is dumb!

 

Really, either works. I find JSON to be easier to create and parse, but it's up to you. If you have data that is already in one format or the other I'd just use that, really the system takes care of it for you.

 

I would also recommend trying to use Push whenever possible. If you can structure your app so data is pushed down to the device whenever there is something new, it will make the app feel much faster and more responsive without having to download new data every time the app starts.

 

For storing the data, you can just write XML or JSON out to your app's private sandbox in the file system. You could also convert it into SQL or something and store it in a SQLite database. Depends on the the data and what you are doing with it, really.

Paul Bernhardt
Application Development Consultant
BlackBerry
@PBernhardt

Did this answer your question? Please accept this post as the solution.
Found a bug? Report it to the Developer Issue Tracker
Please use plain text.
New Developer
Slosh
Posts: 38
Registered: ‎01-24-2014
My Device: Q5

Re: Web Service

[ Edited ]

Hello Zmey, BBSJdev, simon_hain and PBernhardt.

Thanks for helping me

And sorry again to the questions.

 

________________________________________________________________________

 

@Zmey

I've used the example of "bb10pulltorefresh" there is a problem.
I will be writing a new topic.

 

________________________________________________________________________

 

@BBSJdev

I will write a new topic for each problem. :Rolleyes:

 

________________________________________________________________________

 

@simon_hain

Sorry can you clarify that?

 

________________________________________________________________________

 

 

@PBernhardt

Me too I like Json.

It's really good.
It is also the best and easiest to create in PHP:Clap:

 

________________________________________________________________________

 

My new topic:

Pull to Refresh

Please use plain text.
Developer
simon_hain
Posts: 16,190
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Web Service

maybe this helps to clarify the used acronyms
https://stackoverflow.com/questions/16626021/json-rest-soap-wsdl-and-soa-how-do-they-all-link-togeth...
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.