Tuesday, November 25, 2014

Check value exist or Not (AND) Insert the values in Sqlite database using Phonegap

I have written a code that I id not exist insert values of a record in sqlite database.
If already exist just update or do something else. Its just easy way to do.
I have followed this code and written some phonegap application. easy to bind from the sqlite table further use to display the page.
function insertIndustry(industryID,industry)
{
    db = window.openDatabase("mydb","0.1","InsuranceDb", 500000);
    
    var selectQuery ="SELECT COUNT(*) AS MyCount FROM industrymaster WHERE industryId="+industryID;
    db.transaction(function selectQueryDB(tx){tx.executeSql(selectQuery,[],function txSuccessResult(tx,results) {
                          
                              var messageid = results.rows.item(0)['MyCount'];
                               if(messageid == 1)
                                {
                                 console.log("exist");
                                }
                                else
                                {
                                 tx.executeSql("INSERT INTO industrymaster(industryId, industry) VALUES ("+industryID+",'"+industry+"')");
                                }
                              
                             },errorCB);  }, errorDB);
}

function errorCB(err) {
     console.log("Error processing SQL 1: "+err.code);
}

function errorDB(error) {
    console.log(error +"Error processing SQL 1: ");   
}

Check the username and password while User Login in Phonegap

I am working in phonegap application. we have allow only authenticate user. when user login in my application. I want to check the username and password in sqlite database using jquery.
I have created a login page with username and password and if I click the login button it should check if the entered username and password matches with the database(websql) and if it is successfull should go to the next page
Is this correct or should I use some additional methods or steps
If this is not correct may I have a coding to authenticate username and password in sqlite using Jquery/Javascript
var x="SELECT * FROM login WHERE username='"+user+"' AND password='"+pwd+"' ";    
tx.executeSql(x,[],function(tx,result){
          if (result.rows.length > 0){

            alert("Username : " +  result.rows[0].username);
            alert("Password: " + result.rows[0].password); 
          }else{
            alert("User not found!");
          }
    });

Thursday, November 20, 2014

Generate Cordova android jar file and free download cordova-3.5.0 jar file

I want to upgrade my cordova jar file. I just simply created.
Download cordova-android-3.5.0.zip file and extract the zip file.
Just follow the 3 step to generate cordova jar file.

C:\Documents and Settings\cordova-android\framework>android update project -p .
Updated local.properties

Its will build the project local properties file.

build.xml: Found version-tag: custom. File will not be updated.
Added file C:\Documents and Settings\cordova-android\framework\proguard-project.txt

And then you can create ant jar file using this command.

C:\Documents and Settings\cordova-android\framework>ant jar

If ant build xml file is not found you can download the ant package and just set the ant pin folder path as envinoment path
and then you can try ant jar command.
cordova android jar file will build like this

Buildfile: C:\Documents and Settings\cordova-android\framework\build.xml

-pre-build:

-check-env:
 [checkenv] Android SDK Tools Revision 22.3.0
 [checkenv] Installed at C:\Programmi\adt-bundle-windows-x86\sdk

-setup:
     [echo] Project Name: Cordova
  [gettype] Project Type: Android Library

-build-setup:
[getbuildtools] Using latest Build Tools: 18.1.0
     [echo] Resolving Build Target for Cordova...
[gettarget] Project Target:   Android 4.4
[gettarget] API level:        19
     [echo] ----------
     [echo] Creating output directories if needed...
    [mkdir] Created dir: C:\Documents and Settings\cordova-android\framework\libs
    [mkdir] Created dir: C:\Documents and Settings\cordova-android\framework\bin
    [mkdir] Created dir: C:\Documents and Settings\cordova-android\framework\bin\res
    [mkdir] Created dir: C:\Documents and Settings\cordova-android\framework\bin\rsOb
j
    [mkdir] Created dir: C:\Documents and Settings\cordova-android\framework\bin\rsLi
bs
    [mkdir] Created dir: C:\Documents and Settings\cordova-android\framework\gen
    [mkdir] Created dir: C:\Documents and Settings\cordova-android\framework\bin\clas
ses
    [mkdir] Created dir: C:\Documents and Settings\cordova-android\framework\bin\dexe
dLibs
     [echo] ----------
     [echo] Resolving Dependencies for Cordova...
[dependency] Library dependencies:
[dependency] No Libraries
[dependency]
[dependency] ------------------
     [echo] ----------
     [echo] Building Libraries with '${build.target}'...
   [subant] No sub-builds to iterate on

-code-gen:
[mergemanifest] Merging AndroidManifest files into one.
[mergemanifest] Manifest merger disabled. Using project manifest only.
     [echo] Handling aidl files...
     [aidl] No AIDL files to compile.
     [echo] ----------
     [echo] Handling RenderScript files...
     [echo] ----------
     [echo] Handling Resources...
     [aapt] Generating resource IDs...
     [echo] ----------
     [echo] Handling BuildConfig class...
[buildconfig] Generating BuildConfig class.

-pre-compile:

-compile:
    [javac] Compiling 90 source files to C:\Documents and Settings\cordova-android\fr
amework\bin\classes
    [javac] Note: Some input files use or override a deprecated API.
    [javac] Note: Recompile with -Xlint:deprecation for details.
     [echo] Creating library output jar file...
      [jar] Building jar: C:\Documents and Settings\cordova-android\framework\bin\cla
sses.jar

jar:
      [jar] Building jar: C:\Documents and Settings\cordova-android\framework\cordova
-3.5.0.jar

BUILD SUCCESSFUL
Total time: 4 seconds

cordova jar file will be created in your framework folder
cordova android-3.5.0 js file download
Cordova android-3.5.0 jar file download

Guys Cordova android-3.5.1 jar file download codemasterclubs.blogspot.in from this site.

Tuesday, November 18, 2014

Get Jquery mobile dropdown selected Item in Phonegap

I want to get the jquery mobile dropdown selected value and selected text.
this script get the selected text value in phonegap.
$("#yourdropdown option:selected").text();

this script get the dropdown selected value in phonegap.
$("#yourdropdown").val();

Monday, November 17, 2014

Set Environment Variable for Phonegap in Windows

1. Go to Start Menu and right click on Computer. Select Properties.

2. Select Advanced system settings.

3. In the Advanced tab, select Environment Variables.

4. First check the command prompt like this,

Friday, November 14, 2014

Json Parse using javascript

I am working in phone gap application i want to get the json value and display in web page using javascript while when i hot code my json format value.

I can able to get the all the values when i try to get dynamically. I can't get the values so. I have tried the json parse. Its working correctly because the dainamic url values all getting string format. so i can't get correctly.

var json = '{"result":true,"count":1}',
    obj = JSON.parse(json);

alert(obj.count);

Friday, November 7, 2014

Get Current Location using Geolocation plugin in Phonegap

I am working in phonegap application in my application i want to use Geolocation plugin used for get CurrentLocation in android and ios device.

I have done. just following this instruction.

I have posted the sample application using local development.Download

cordova plugin add https://github.com/apache/cordova-plugin-geolocation.git

Permissions Android

app/res/xml/config.xml

<feature name="Geolocation"><param name="android-package" value="org.apache.cordova.geolocation.GeoBroker"></feature>

app/AndroidManifest.xml

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />

IOS 8: just u can add this two option


code:2 message: the operation couldn't be completed. (kCLErrorDomain error 0)

I am working in Phonegap application. when i used Geolocation plugin for getCurrentlocation in simulator i got the error message.



code:2 message: the operation couldn't be completed. (kCLErrorDomain error 0).


because of this error will come while u didn't send the location menually.

just follow this: