在android中找到SQLite数据库的位置?

时间:2014-04-21 08:06:54

标签: android sqlite

这是我在下面给出的代码:

public class DBHelper extends SQLiteOpenHelper {
    private static final String DBNAME = "acc_db.db";

    private static final int VERSION = 4;


    private static DBHelper dbHelper = null;

    private static SQLiteDatabase db = null;

    private DBHelper(Context context) {
        super(context, DBNAME, null, VERSION);
        // storing the object of this class to dbHelper
        dbHelper = this;
    }


    @Override
    public void onCreate(SQLiteDatabase database) {
        DBTable.onCreate(database);
    }

    // Method is called during an upgrade of the database,
    // e.g. if you increase the database version

    @Override
    public void onUpgrade(SQLiteDatabase database, int oldVersion,
            int newVersion) {
        DBTable.onUpgrade(database, oldVersion, newVersion);
    }
    public static DBHelper getInstance(Context context) {
        if (dbHelper == null) {
            dbHelper = new DBHelper(context);
            openConnecion();
        }
        return dbHelper;
    }

    // will be called only once when singleton is created

    private static void openConnecion() {
        if (db == null) {
            db = dbHelper.getWritableDatabase();
        }
    }


    public synchronized void closeConnecion() {
        if (dbHelper != null) {
            dbHelper.close();
            db.close();
            dbHelper = null;
            db = null;
        }
    }
}

其中找到acc_db.db。 我将搜索File Explorar =>数据/数据 但未在数据文件夹下找到数据子文件夹。 [N.B]我使用此数据库成功完成了CRUD操作。 请帮助我任何身体。

2 个答案:

答案 0 :(得分:0)

数据库位于应用的私有区域。在数据库文件夹下。例如/data/data/com.whatsapp/databases

答案 1 :(得分:0)

它位于/data/data/my.package.name/databases/