/** * Open a database. * * @param dbName The name of the database file */ private SQLiteAndroidDatabase openDatabase(String dbname, CallbackContext cbc, boolean old_impl) throws Exception { try { // ASSUMPTION: no db (connection/handle) is already stored in the map // [should be true according to the code in DBRunner.run()] File path = Environment.getExternalStorageDirectory(); File newPath = constructFilePaths(path.toString(), name); File dbfile = this.cordova.getActivity().getDatabasePath(dbname); if (!dbfile.exists()) { dbfile.getParentFile().mkdirs(); } Log.v("info", "External path: " + newPath.getAbsolutePath()); Log.v("info", "Open sqlite db: " + dbfile.getAbsolutePath()); SQLiteAndroidDatabase mydb = old_impl ? new SQLiteAndroidDatabase() : new SQLiteDatabaseNDK(); mydb.open(dbfile); if (cbc != null) // XXX Android locking/closing BUG workaround cbc.success(); return mydb; } catch (Exception e) { if (cbc != null) // XXX Android locking/closing BUG workaround cbc.error("can't open database " + e); throw e; } }
public static long backupExists(ApplicationInfo in){ PackageInfo i = null; String PATH = Environment.getExternalStorageDirectory().getPath(); try { i = nPManager.getPackageInfo(in.packageName, 0); } catch (NameNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } File file = new File(PATH + "/File Quest/AppBackup"); if( file.exists() && new File(PATH + "/File Quest").exists()){ for(File f:file.listFiles()){ String out_file = nPManager.getApplicationLabel(in) + "-v"+i.versionName + ".apk"; if(f.getName().equals(out_file)){ return f.lastModified(); } } } return 0; }