删除自己应用下的所有db数据库文件,代码如下:
String[] arr = context.databaseList();
for (int i = 0; i < arr.length; i++) {
context.deleteDatabase(arr[i]);
}
具体api介绍
根据创建的db数据库名称,删除db数据库文件
android.content.Context.deleteDatabase(String name);
/**
* Delete an existing private SQLiteDatabase associated with this Context's
* application package.
*
* @param name The name (unique in the application package) of the
* database.
*
* @return {@code true} if the database was successfully deleted; else {@code false}.
*
* @see #openOrCreateDatabase
*/
public abstract boolean deleteDatabase(String name);
列出本应用的所有db数据库文件
android.content.Context.databaseList()
/**
* Returns an array of strings naming the private databases associated with
* this Context's application package.
*
* @return Array of strings naming the private databases.
*
* @see #openOrCreateDatabase
* @see #deleteDatabase
*/
public abstract String[] databaseList();
参考
https://blog.csdn.net/silenceisall/article/details/84473096