某些表的动态数据库备份

某些表的动态数据库备份

本文介绍了某些表的动态数据库备份的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只需要备份主数据库中的某些表.其他表是参考表,它们是静态的,因此不需要备份.

I need to backup just some of the tables in my main database. The other tables are reference and are static so do not need to be backed up.

我在SDCARD上创建了一个新的空白DB.我可以直接在SDCARD上访问数据库吗,或者在备份完成后是否需要复制该数据库?

I have created a new blank DB that is on the SDCARD. Can I access the DB directly on the SDCARD or do I need to copy it when its finished backup?

真正的问题是,我可以循环访问每条记录中的字段或其他什么东西,这样我就不必有数百行代码,每个字段一个.

The real question is can I iterate through the fields in each record in a loop or something so I dont have to have hundreds of line of code, one for each field.

在VB .NET中,我会做类似的事情

In VB .NET I would do something like

For X = 0 to RS.Fields.Count
 NewRS.Fields(x).value = Rs.Fields(x).value

等等...我在Android中怎么受伤?

etc... How wound I do that in android?

推荐答案

我编写了一个用于处理此问题的类.是的,我的数据库至少有95%参考...

I wrote a class to handle this. Yes my DB is at least 95% reference...

这是代码的胆量:

Cursor c = DbBak.rawQuery(Sql, null);
            String Cn[] = c.getColumnNames();

            if (c != null ) {
                if  (c.moveToFirst()) {
                    do {
                        for ( x=0; x< c.getColumnCount(); x++)
                        {
                            newRow.put(Cn[x].toString(), c.getString(x));
                        }

                        Db.insert(TableName,  null, newRow);

                    }while (c.moveToNext());

这篇关于某些表的动态数据库备份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 00:18