如何获得Android中当前SQLite数据库的大小或包装大小? [英] How to get the current sqlite database size or package size in Android?

查看:404
本文介绍了如何获得Android中当前SQLite数据库的大小或包装大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法通过Android应用程序(或程序包)使用的数据总量,因为官方的API支持已被删除:

I can't get the total amount of data used by an Android Application (or package), because the official API support has been deleted:

<一个href=\"http://groups.google.com/group/android-developers/browse_thread/thread/df94daae34336aad/f96a8425549c6637\" rel=\"nofollow\">http://groups.google.com/group/android-developers/browse_thread/thread/df94daae34336aad/f96a8425549c6637 (这仍然是目前的状况?)

http://groups.google.com/group/android-developers/browse_thread/thread/df94daae34336aad/f96a8425549c6637 (is this still the current situation?)

获取安装的应用程序的大小(unsopported黑客 - 不使用它)

Getting installed app size (unsopported hack - do not use it)

那么,有没有办法让目前的SQLite数据库的大小?我发现一个getMaxSize方法或为getpagesize但我无法找到的页面总数。

So is there any way to get the current sqlite database size? I've found a getMaxSize method or getPageSize but I'm not able to find the total number of pages.

推荐答案

也许有人可以验证这是否是一个可以接受的方法,但是一会我是用这样的:

Perhaps someone could verify if this is an acceptable approach, but for a while I was using this:

File f = context.getDatabasePath(dbName);
long dbSize = f.length();

干杯

这篇关于如何获得Android中当前SQLite数据库的大小或包装大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆