11
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[Android] DBファイルを削除する

Posted at

概要

Context#deleteDatabase()を実行すると、/data/data/packageName/配下にあるアプリ自身が持つDBファイルを削除できる。

サンプルコード

MainAcitivity.java

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // 引数の「xxx.db」部分はDBファイル名を指定
        deleteDatabase("xxxx.db");

    }


11
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?