Access data from webView in cordova/android - javascript

I have following situation and didn't find the answer to my question in my searches. I am sorry if I overlooked something.
I am using cordova for an android app. This app isn't more than an existing web page/web application repackaged as an android app. This web application gets data using existing and working api calls in form of http requests.
All good, but this data is only available online. I need to build a local database in android to have the data available offline as well.
Question: How do I access this data and put it into an Activity?
Thank you in advance

You can use localStorage to do that.
https://cordova.apache.org/docs/en/latest/cordova/storage/storage.html
If you want to save a json than you will have to stringify it first.

Related

Dialogflow API how to send request using the api

I have developed a small chat application using dialogflow fallowing this tutorial.
https://dialogflow.com/docs/getting-started/basic-fulfillment-conversation
this works fine. i want to send requests to this application from my alredy developed web application instead of using their web view (Web Demo). I thought it should be possible with their api (https://dialogflow.com/docs/reference/api-v2/rest). but their is no api exposed to send queries. am i missing something or is there no way to do this. ?
They changed the name fairly dramatically, and the names of many of the fields in the JSON, but the function is pretty much the same. You'll need to use the project.agent.sessions.detectIntent method.
You can find all the details about Dialogflow RESTful API here.
As Prisoner mentioned, you can use
POST /v2/{session=projects/*/agent/sessions/*}:detectIntent
For v2.projects.agent.sessions

Is it possible to connect your background script to mongoDB server? If Yes, How?

I am creating a google chrome extension. I have a background script from which I want to send and retrieve some data from MongoDB database. How do I do that? I'm new in chrome extension development.
YES. It's possible. But, It's not a good idea to expose a database to the public internet at all. Implement a REST like method in your backend code and authorize calls to it using some web standard auth scheme, such as OAuth or HTTP Basic auth. Hitting the DB directly is way too dangerous. You can receive/send data from DB accordingly. Saying That if you still want to go ahead here's a link to help you with that For full REST capabilities, consider using an external REST Interface such as Sleepy.Mongoose.

Storing data while processing an app through phonegap

I am using the Phonegap platform for developing an app and this runs on nexus 5 android 4.
The app is having a user interface through which it takes input from the user and processes it using the Javascript. My question is: Can I store/capture this data somewhere so that I can utilize it later. The utility can be sending the captured data to another server and getting a response from it for the specific data.
What is the best architectural way to accomplish this? Any thoughts highly appreciated.
There are many options to do this, IndexedDB, SQLite, localStorage, sessionStorage which are all HTML5 standards.
You might even be able to use XML file storage to do this.
Its your preference on what works best for you.

JavaScript localstorage between multiple web apps?

One of my web apps (for iOS) save something with javascript localstorage.
For some reason, I can access that data from that same web app, but not from another one, which is on the same website.
I really need to do this, so why doesn't it work?
And, more importantly, how can I fix it?
This is just a hack, you can use web messaging between apps to share localstorage data.
Resources you can find about web messaging
https://developer.mozilla.org/en-US/docs/Web/API/window.postMessage
http://www.w3.org/TR/webmessaging/

Creating my first Mobile App and connecting it to a database

I have to create a Windows Phone 7 app as part of a research project. The app needs to:
Allow the user to login by connecting to an sql server database (stored locally for the purpose of this project)
If login successful, return a list of products associated with the user (i.e. in product table where UserID=x)
User can click on an item in the list, and then add photos for that item. This can be done offline as well (using HTML5 offline storage)
When an internet connection is available again, user can click 'Upload' (or automatically synced, but not necessary) and the images are all uploaded to the Images table with the correct ProductID as Foreign key
Since this is the first time I am doing any mobile programming, I am not sure what is the best approach. I am especially unsure of how I am going to connect to the database. I'm not really interested in learning Silverlight, so the app should use mainly HTML5 and javascript, I also am looking into JQueryMobile.
I have already installed PhoneGap and am trying it out, but my main concern is how to connect the app to the database as I am having trouble finding the 'proper' way of doing this e.g. using some kind of web service or directly through javascript (read it can be done but is not recommended). If anyone could recommend or suggest a good approach of doing this that would be great!
SqlServer is only available on the phone via LinqToSql which you need to expose via a service or a DAL. I dont think that its possible to make calls directly from Javascript to LinqToSql on the phone.
If you're not set on the idea that the DB needs to be on the phone, you can just make service calls via ajax to a server and access the db that way. I recently did a blog post exposing a db via a WCF Data service and consuming it on the phone. It doesn't cover calling it via ajax but should help get you started.
http://www.ritzcovan.com/2012/02/building-a-simple-windows-phone-apppart-4/
If you want to store data within the WP7 database, use the PhoneGap storage APIs.

Categories

Resources