cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "saurabh Trivedi (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (CB-3550) Undefined error while open database when comes back from inappBrowser link: android
Date Fri, 31 May 2013 07:14:19 GMT

    [ https://issues.apache.org/jira/browse/CB-3550?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13671216#comment-13671216
] 

saurabh Trivedi edited comment on CB-3550 at 5/31/13 7:14 AM:
--------------------------------------------------------------

Hello Joe bowser thanks for reply , however my question was on some other expects like I am
developing a android based application through Phonegap(Jscript, HTML5) , on my application
i saved dataBase with .db extension in assets folder and on very starting of application copy
the database to app database file, every thing is fine till now , able to do transaction to
database successfully fetching the data from db , but the problem is when i am opening the
external Link (Browser) from my app and comes back to my app and if now i do any type of query
from db its throwing error as "Undefined". my code for fetching the data from database is
Below. so where is the problem while i have database , its should not be lost.


  code for copying the database from my assets folder is:
   

    @Override
	public void onCreate(Bundle savedInstanceState) {
		try {

			this.copy("Databases.db", "/data/data/" + pName + "/app_database/");
			this.copy("0000000000000001.db", "/data/data/" + pName
					+ "/app_database/file__0/");
			super.onCreate(savedInstanceState);
			super.setIntegerProperty("splashscreen", R.drawable.splash);

			super.loadUrl(
					"file:///android_asset/www/index.html",
					2000);
}

    void copy(String file, String folder) throws IOException {

		Log.d("GRT", "We are in the copy of db");
		File CheckDirectory;
		CheckDirectory = new File(folder);
		if (!CheckDirectory.exists()) {
			Log.d("GRT", "Creating copy of db db");
			CheckDirectory.mkdir();
		} else {
			Log.d("GRT", "Databse already exists");
		}

		InputStream in = getApplicationContext().getAssets().open(file);
		OutputStream out = new FileOutputStream(folder + file);

		// Transfer bytes from in to out
		byte[] buf = new byte[1024];
		int len;
		while ((len = in.read(buf)) > 0)
			out.write(buf, 0, len);
		in.close();
		out.close();

	}



    function queryRecommded(){   
    var db = window.openDatabase("Database", "1.0", "GRTDB", 200000);
    db.transaction(queryRecommondedProduct, errorCB2, successCB);
    }
}
function queryRecommondedProduct(tx){
try{
    //alert("SQL gonna run now");
   var progressHud =window.plugins.waitingDialog;
   progressHud.show("Loading...Please wait");      
   tx.executeSql("Select aa.ProductID,aa.ProductName,aa.Price,aa.Description,aa.Specification,aa.VideoLink,ab.GalleryID,ab.Location,ab.ImageName,ab.LocalFolder,aa.Buy_Now
from tblProduct aa inner join tblGallery ab on aa.ProductId=ab.ProductId where aa.ProductId=(select
RecomProdId  from tblQuery where AnswerQ1='"+shouseType.toLowerCase()+"' AND  AnswerQ2='"+lawnSize.toLowerCase()+"'
AND AnswerQ3='"+lawnobstacle.toLowerCase()+"' AND AnswerQ4='"+trimmingneeds.toLowerCase()+"'
AND AnswerQ5='"+strimfreq.toLowerCase()+"' AND IsDeleted='0' ORDER BY ProductAnswerId ASC
LIMIT 1  ) and aa.IsDeleted ='0' and ab.IsDeleted ='0' and ab.IsDownLoad ='1'", [],function(tx,result){queryRecommdedSuccess(tx,result,"isReccom")},
errorCB4);           
}
catch(e)
{
     alert("test"+e);
}
}

after executing my "queryRecommondedProduct" controls goes over to errorCB4 method with error
Undefined. Please look at this.
                
      was (Author: saurabh26213):
    Hello Joe bowser thanks for reply , however my question was on some other expects like
I am developing a android based application through Phonegap(Jscript, HTML5) , on my application
i saved dataBase with .db extension in assets folder and on very starting of application copy
the database to app database file, every thing is fine till now , able to do transaction to
database successfully fetching the data from db , but the problem is when i am opening the
external Link (Browser) from my app and comes back to my app and if now i do any type of query
from db its throwing error as "Undefined". my code for fetching the data from database is
Below. so where is the problem while i have database , its should not be lost.


  code for copying the database from my assets folder is:
   

    @Override
	public void onCreate(Bundle savedInstanceState) {
		try {

			this.copy("Databases.db", "/data/data/" + pName + "/app_database/");
			this.copy("0000000000000001.db", "/data/data/" + pName
					+ "/app_database/file__0/");
			super.onCreate(savedInstanceState);
			super.setIntegerProperty("splashscreen", R.drawable.splash);

			super.loadUrl(
					"file:///android_asset/www/index.html",
					2000);
}

    void copy(String file, String folder) throws IOException {

		Log.d("GRT", "We are in the copy of db");
		File CheckDirectory;
		CheckDirectory = new File(folder);
		if (!CheckDirectory.exists()) {
			Log.d("GRT", "Creating copy of db db");
			CheckDirectory.mkdir();
		} else {
			Log.d("GRT", "Databse already exists");
		}

		InputStream in = getApplicationContext().getAssets().open(file);
		OutputStream out = new FileOutputStream(folder + file);

		// Transfer bytes from in to out
		byte[] buf = new byte[1024];
		int len;
		while ((len = in.read(buf)) > 0)
			out.write(buf, 0, len);
		in.close();
		out.close();

	}



    function queryRecommded(){   
    var db = window.openDatabase("Database", "1.0", "GRTDB", 200000);
    db.transaction(queryRecommondedProduct, errorCB2, successCB);
    }
}
function queryRecommondedProduct(tx){
try{
    //alert("SQL gonna run now");
   var progressHud =window.plugins.waitingDialog;
   progressHud.show("Loading...Please wait");      
   tx.executeSql("Select aa.ProductID,aa.ProductName,aa.Price,aa.Description,aa.Specification,aa.VideoLink,ab.GalleryID,ab.Location,ab.ImageName,ab.LocalFolder,aa.Buy_Now
from tblProduct aa inner join tblGallery ab on aa.ProductId=ab.ProductId where aa.ProductId=(select
RecomProdId  from tblQuery where AnswerQ1='"+shouseType.toLowerCase()+"' AND  AnswerQ2='"+lawnSize.toLowerCase()+"'
AND AnswerQ3='"+lawnobstacle.toLowerCase()+"' AND AnswerQ4='"+trimmingneeds.toLowerCase()+"'
AND AnswerQ5='"+strimfreq.toLowerCase()+"' AND IsDeleted='0' ORDER BY ProductAnswerId ASC
LIMIT 1  ) and aa.IsDeleted ='0' and ab.IsDeleted ='0' and ab.IsDownLoad ='1'", [],function(tx,result){queryRecommdedSuccess(tx,result,"isReccom")},
errorCB4);           
}
catch(e)
{
     alert("test"+e);
}
}
                  
> Undefined error while open database when comes back from inappBrowser link: android
> -----------------------------------------------------------------------------------
>
>                 Key: CB-3550
>                 URL: https://issues.apache.org/jira/browse/CB-3550
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Android
>    Affects Versions: 2.7.0
>            Reporter: saurabh Trivedi
>            Assignee: Joe Bowser
>
> save db file on assets folder , on application launch time copy database to application
database file, successful open database and fetch data from db, navigate to external link
using IN app browser and come back to my application, getting database Undefined while fetching
again data from db ,database connectivity Issues occurring, and error is Undefined. 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message