database table not being created in phonegap - javascript

I have a working web app developed using jquery mobile, html5, javascript. I created an android project in phonegap using the html and js files that i already had. The application launches properly on the emulator and I can see all the pages are being loaded fine. In one of the pages I have to save form data in the database. I can see the database creation is happening properly but the table is not being created. This is the code where i'm creating the table in the js file,
db.transaction(function (tx) {
tx.executeSql('CREATE TABLE IF NOT EXISTS exp (
id INTEGER PRIMARY KEY,
ename VARCHAR(30),
amount DECIMAL(4,2),
category TEXT,
date DATE)',[]);
});
I'm confused and don't even know where to start looking as to what is going wrong.

There seems to be some issue with the phonegap since I was not even able to run the database example provided by them on the website. Still you can achieve this functionality by creating a plugin for phonegap and accessing the database using the android code.
convert the data from database to json and pass it to the phonegap js file.Refer to this page to know how how it can be done:
http://wiki.phonegap.com/w/page/36753494/How%20to%20Create%20a%20PhoneGap%20Plugin%20for%20Android

Related

I want to convert an huge excel workbook (with multiple tabs) and few columns and rows hidden on WEB Page

When I tried saving the excel sheet in HTML and displaying I've got few problems:
The numbers in each cell are distorted
Hidden rows and columns are displayed (I want them to keep hidden)
Top rows of my Excel sheet are freezed, I want them to keep freezed.
The Sheet is updated daily and I want the changes to be reflected in Web as well.
Could you suggest a way other than saving excel sheet in HTML? Any other way I could start this project?
P.S: I hold the knowledge of HTML, CSS, JavaScript.
Do I need to learn any additional skill set to get pull this project?
If you are running IIS or can otherwise run .NET code on your server, you can use the Open XML SDK. There are plenty of examples of using the SDK. Apparently, it even works with Mono if you're using Apache.
If not, if you've got some machine that can get to the Excel file and copy files to your web server and from which you can run a scheduled task, you can schedule a task on that machine that using the Open XML SDK to translate the Excel file to HTML, then upload that HTML to the server.
It doesn't have to be a complete page; it can just be the parts of the HTML you need. You can then have some JavaScript on the page that fires off an AJAX request to get the HTML file. This is true regardless of whether your serving content dynamically generated by code running under IIS or a static file generated by code elsewhere and pushed to the server.
You might have something like:
<!-- page where the spreadsheet should go -->
<div id="put-excel-worksheet-here"></div>
Then:
$.ajax({
url: "/path/to/converted-data-partial-html.html"
, success: function(excelHtml) {
$("#put-excel-worksheet-here").append($(excelHtml));
}
});
And your ASP.NET page response or scheduled task would convert your Excel file to something like <table><thead><tr><th id='column-one-th'>....
Either way, I'd recommend you work with a copy of the file rather than the original, since I've found Office can get a little finicky with files being open in two places at once.
As for freezing the top rows, here's a fiddle with an example.
Good luck!
edit: As an alternative to putting millions of cells worth of HTML onto a single page, it might make sense load the Excel data into a relational database like MySQL or Microsoft SQL Server and do some custom web development to pull the data out of that with pagination and filters and other nice reporting features.
If the data in the Excel file is coming OUT of another system, you might be able to set up a system-to-system integration. If not through an integration, though, the Open XML SDK is how I'd do it. You don't have millions of rows to put up per your comments above, so this suggestion doesn't make sense.
edit: Oh, and I recommend your scheduled task run during a time when people aren't likely going to be using the system. If, for example, your users are all in a few adjacent time zones, have the task run at 3:00 AM in the Eastern-most time zone.

How to show an android app which uses webview is up to date

I'm trying to develop an offline android app using simple html, css and javascript. I use website2apk software to convert the local html files to a standalone apk file.
My app contains a tariff of some random products. What i need is to notify (in-app notification) my app user if there is any update to the app.
For example, when user get connected to internet the app should automatically check for updates and if there is any update available, a warning should appear on top of the home page which says "New Update Available" which will be linked to mysite.com/newversion.apk .
Can someone suggest me what to do for this?. I can only depend Webview and pure javascript, which means no jquery.
I'm sorry for my bad English. Thanks in advance.
The site which hosts your apk should have an api so you can check from your app if there is any newer version available.
A possible solution would be to add a file (for example a json file) which contains the actual version of your app. Then you can make a web request in your app to get the file data.
Example:
get 'http://www.yourwebsite.com/appversion.json'

Create a donwloadable content Apps with Javascript and HTML5 for Mobile Devices

Hello Everyone and thanks for taking the time to answer my question!
I want to create a simple app to display up to date information to our client. The App should check the latest "data" on the server every time the aplication start and download it to the client. That way the app will be able to use that "data" to show the information.
Does anyone know how I can do that with only JavaScript or maybe a JSON file and HTML5, or do you have any suggestion the best way to do something like that?
Thank you in advance!
You can generate JSON on yor server and parse that on the mobile device to display the data.
It's generally better to use native code instead of wrapping a HTML Application into your Android App. That way you can also use Google Material Design.
Assuming you don't want to write a separate native app for both Android and IOS, you could create a single mobile application using PhoneGap that is just a single HTML page with Javascript that does an XHR call to your server when it loads and stores the response JSON locally. PhoneGap allows you to compile versions for IOS and Android from a single codebase.
With PhoneGap there is a handler that gets called when the app loads that you can use:
function onDeviceReady() {
$.getJSON("http://yourserver/yourfile.json", function( data ) {
//do whatever you want with the data to store it
})
}

reading & writing sqlite database with javascript

I am currently trying to get my head around database's and web programming.
I currently have 3 files index.html, script.js (empty at the minute) and test_db.sqlite.
I am trying to pull info from the sqlite database, create a javascript variable with the info and the print it to the html with the document.getElementById method.
What I'd having trouble with is reading the database using javascript. I am willing to use jquery or any other extra JS scripts, but I cannot use php as I intend to use this to create a cross platform app with a python web wrapper on windows & linux and phonegap for iOS and Android.
I also need to figure out to write to the database with javascript.
Thank you for any help in advance.
You have to dump the database (you can use .dump command in sqlite3)
Then you can send that dump to de front-end (the navigator)
You can use WebSql API to create the database and execute all commands of the dump to recreate
Warning, this does'nt work in Firefox. It works only in Chrome and Safari

Set a filled sqlite default database in a chrome app

I have written an app using javascript , it uses websql as its database, when I open it in chrome everything works fine. it uses a filled database table which is like a dictionary. I mean the app needs the database to run correctly. The problem is that when I want to use it on another computer I need to transfer the database to where chrome databases are and rename it to the currently created sqlite file that is created by running the program first (with database not found error of course). The question is how can I automate this? , I've tried deskshell and tidesdk but it still doesn't work. tidesdk doesn't even render the css correctly. deskshell doesn't create the app and the database problem is still unresolved.

Categories