List of usage examples for android.content Context databaseList
public abstract String[] databaseList();
From source file:Main.java
public static void deleteAppDatabases(Context context) { String[] dbs = context.databaseList(); if (dbs == null || dbs.length == 0) return;/*from w ww. j a v a 2 s .co m*/ for (String db : dbs) { context.deleteDatabase(db); } }
From source file:Main.java
public static List<String> getDatabaseList(Context context) { String[] strDatabaseList = context.databaseList(); List<String> list = new ArrayList<>(); if (strDatabaseList != null) { for (String name : strDatabaseList) { if (name.startsWith(DATABASE_START) && name.endsWith(DATABASE_TYPE)) { list.add(name.substring(0, name.length() - DATABASE_TYPE.length())); }/*from w w w. j a va2 s. c o m*/ } } return list; }
From source file:com.yattatech.dbtc.util.DbUtil.java
/** * Copies the application database to given folder, it' very useful * for debugging purpose only.//from ww w . ja va2s. c o m * * @param path * */ public static void copyDatabase(String path) { final File folder = new File(path); final Context context = DBTCApplication.sApplicationContext; if (!folder.exists()) { folder.exists(); } for (String database : context.databaseList()) { final File dbFile = context.getDatabasePath(database); InputStream in = null; OutputStream out = null; try { in = new FileInputStream(dbFile); out = new FileOutputStream(new File(folder, database)); IOUtils.copy(in, out); } catch (IOException ioe) { Debug.d(TAG, "Failed:", ioe); } finally { IOUtils.closeQuietly(in); IOUtils.closeQuietly(out); } } }
From source file:Main.java
/** * Copy database files to the given folder. Useful for debugging. * * @param folder the directory to copy files into *///from ww w .j a va2 s. c o m public static void copyDatabases(Context context, String folder) { File folderFile = new File(folder); if (!folderFile.exists()) { folderFile.mkdir(); } for (String db : context.databaseList()) { File dbFile = context.getDatabasePath(db); try { copyFile(dbFile, new File(folderFile.getAbsolutePath() + File.separator + db)); } catch (Exception e) { Log.e("ERROR", "ERROR COPYING DB " + db, e); } } }