title: table not found when coming back from in app browser link: Phonegap
body: <p>I am developing a phone-gap application for android, save database with .db extension in assets folder , on java file of application i did copy database to my application database (code is below), now suppose i have two buttons (one for open external link and other is for open database and fetching data from db) . upon launching of application when i click for fetching data from db button its success full and execute the query , and now when i click on button for open inapp browser link from my app its open the link in inappbrowser and now i click back button and we are our application page now if i click on button for fetching the data from database its sending error "SqliteDatabaseCpp(28065): sqlite returned: error code = 1, msg = no such table: tblProduct
  "  </p>
  
  <p>so pls any one could suggest me where i am wrong , my code for copy database  and execute query are below:</p>
  
  <p><strong>Java code for copy data to database:</strong></p>
  
  <pre><code>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.loadUrl(
              "file:///android_asset/www/index.html",
              2000);
      super.appView.setVerticalScrollBarEnabled(true);
      super.appView.setHorizontalScrollBarEnabled(false);
      super.appView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
  
  } catch (IOException e) {
      e.printStackTrace();
  }
  }
  
   // Copy Paste this function in the class where you used above part
  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)) &gt; 0)
      out.write(buf, 0, len);
  in.close();
  out.close();
  
  }
  </code></pre>
  
  <p><strong>HTML buttons(one for open inappbrowser and other is query for database):</strong></p>
  
  <pre><code> &lt;a data-role="button" onclick="openInapp()"&gt;open inapp browser&lt;/a&gt;
  </code></pre>
  
  <p></p></p>
  
  <pre><code> &lt;a  data-role="button" onclick="queryRecommded()"&gt;View Recommended Product&lt;/a&gt;
  </code></pre>
  
  <p><strong>corresponding .js file code is :</strong></p>
  
  <pre><code>function onDeviceReady()
   {
  
     var db = window.openDatabase("Database", "1.0", "GRTDB", 3000000);
  
     db.transaction(queryRecommondedProduct, errorCB2, successCB);
  
  
    }
  
    function queryRecommondedProduct(tx){
      console.log("tx"+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='"+"townhouse"+"' AND  AnswerQ2='"+"small"+"' AND AnswerQ3='"+"several"+"' AND AnswerQ4='"+"medium duty"+"' AND AnswerQ5='"+"monthly"+"' 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);}
  }
   function queryRecommdedSuccess(tx,result,rflag){
  
      console.log("Step2"+result.rows.length)
    // alert("Step2 - "+result.rows.length);
      if(result.rows.length&gt;0){
  
  
      }
      }
  
  function errorCB2(err){
      alert("Error2 is::--- "+err.code);
  }
  
  
  function successCB(){
  }
   function **queryRecommded**()
   {
  
     document.addEventListener("deviceready", onDeviceReady, false);
   }
  
   function openInapp(){
  
    iabRef = window.open('http://apache.org', '_blank', 'location=yes');
    iabRef.addEventListener('loadstart', iabLoadStart);
    iabRef.addEventListener('loadstop', iabLoadStop);
    iabRef.removeEventListener('loaderror', iabLoadError);
    iabRef.addEventListener('exit', iabClose);
   }
  </code></pre>