You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "saurabh Trivedi (JIRA)" <ji...@apache.org> on 2013/05/31 09:12:19 UTC

[jira] [Commented] (CB-3550) Undefined error while open database when comes back from inappBrowser link: android

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

saurabh Trivedi commented on CB-3550:
-------------------------------------

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