问题描述
有没有什么办法,如何创建和我的应用程序,而不是/data/data/com.myapp/databases目录使用的数据库从SD卡?我知道它是不安全的,但是否有任何特殊的限制,如在SD卡上的数据库不能更大然后2GB?
is there any way, how to create and use database from SD card in my app instead of /data/data/com.myapp/databases directory? I know is it unsecure, but are there any special restriction like "database on SD card cannot be bigger then 2GB"?
感谢
Hmyzak
推荐答案
他是一个提议的解决方案,我发现在计算器
he is a proposed solution which i found in stackoverflow
File dbfile = new File("/sdcard/android/com.myapp/databases/mydatabase.db" );
SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase(dbfile, null);
System.out.println("Its open? " + db.isOpen());
这里是 link.
here is the link.
更新
我不知道,你可以使用这个随着SQLiteOpenHelper,但你肯定可以查询数据库对象。
i am not sure you can use this along with SQLiteOpenHelper, but you sure can query the database object.
db.getVersion();
db.execSQL(sql);
db.beginTransaction();
db.endTransaction();
db.setTransactionSuccessful();
db.query(table, columns, selection, selectionArgs, groupBy, having, orderBy);
你可以做所有你期待着与数据库中的东西。 SQLiteOpenHelper只有一个包装类,它可以帮助你,我们总能在我们自己做多余。
you can do all the things which you expect with a database. SQLiteOpenHelper in only a wrapper class which helps you the extra which we always can do on our own.
修改为您的文件大小限制,我发现这个链接。 Is有在Android蜂窝文件大小限制?
EDITas for your file size limit i found this link. Is there a file size limit on Android Honeycomb?
这篇关于Android的 - 在SD卡上的SQLite数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!