如何确定机器人的最大数据库的大小和prevent SQLiteFullException? [英] How to determine android database max size and prevent SQLiteFullException?

查看:390
本文介绍了如何确定机器人的最大数据库的大小和prevent SQLiteFullException?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Android的SQLiteDatabase几个疑问

1)由于通常存储在内存中的数据库,我们可以指定外部存储的路径,并用它在类似的方式? 2.)如何确定的数据库的可用空间的大小?我用调用getMaximumSize()从SQLIteDatabase类,但是这给了我1099511626752 这是字节?如果假定然后这似乎是过大,不实用。我使用的HTC G1进行测试。 3)我如何确定一个表项的大小?或者,我要拉整个表并手动看到它的大小。是不是相同的,这将是在手机的存储? 4)我可以检查是否可用在制作数据库条目之前,任何的自由空间?我想prevent SQLiteFullException。

感谢。

解决方案
  

正如通常存储在内部存储器中的数据库,可以我们指定的外部存储的路径和使用它   以类似的方式

据我所知,是的,但你将无法使用 SQLiteOpenHelper

  

如何确定数据库可用空间的大小?我用调用getMaximumSize()从SQLIteDatabase类   但是这给了我1099511626752这是字节?如果假定然后这似乎是过大和不   实用。我使用的HTC G1进行测试。

我希望,这将是调用getMaximumSize()和可用空间,无论你已在数据库中的存储量较小。

  

我怎么能确定一个表项的大小?

我不知道的条目的,更不用说如何计算它的大小。

  

我可以检查是否有可用空间使得进入数据库之前?

不容易,AFAICT。 Android不具备 getFreeSpace()方法对文件

I have few queries on Android SQLiteDatabase

1.) As normally the database stored in internal memory, can we specify the path of external storage and use it in similar way ? 2.) How to determine the size of available space of database ? I used getMaximumSize() from SQLIteDatabase class but that gives me 1099511626752 Is this in bytes ? If assumed then this seems to be too large and not practical. I am using HTC G1 to test this. 3.) How can I determine the size of an entry in table ? Or do I have to pull the whole table and manually see its size. Is it same that would be in phone storage ? 4.) Can I check if any free space available before making entry in database ? I want to prevent SQLiteFullException.

Thanks.

解决方案

As normally the database stored in internal memory, can we specify the path of external storage and use it in similar way

As I understand it, yes, though you will not be able to use SQLiteOpenHelper.

How to determine the size of available space of database ? I used getMaximumSize() from SQLIteDatabase class but that gives me 1099511626752 Is this in bytes ? If assumed then this seems to be too large and not practical. I am using HTC G1 to test this.

I expect that it would be the smaller of getMaximumSize() and the amount of free space available wherever you have the database stored.

How can I determine the size of an entry in table ?

I have no idea what "an entry" is, let alone how to compute its size.

Can I check if any free space available before making entry in database ?

Not easily, AFAICT. Android does not have the getFreeSpace() method on File.

这篇关于如何确定机器人的最大数据库的大小和prevent SQLiteFullException?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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