android 删除sqlite数据库

删除自己应用下的所有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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值