开发者

How can I split my db into 1 mb pieces?

I have a sqlite db named sports.db that is 9.8 mb in size. I would like to split it up in Terminal into 1mb pieces (I hate you Android), what is the terminal command syntax that will do that for me?

split 1 sports.db didn't do it for me...

EDIT:

It is possible to cut a file up into raw binary pieces in DOS, or the mac equivalent Terminal. 开发者_运维百科That's all I want to do. I just can't figure out the syntax.

Thanks

LATE UPDATE:

This is what worked for what I wanted -

split -b 1m input prefix

where input and prefix are your input file and what you want the prefix of your output files to be


I don't fully understand what u want to do. But if u want to copy database into sd-card or internal storage from assets, I have some solution u might need. Split the database into 1MB using hj-split and Copy using InputStream. Here is some code for u

    InputStream databaseInput = null;
    String outFileName = DB_PATH + DB_NAME;\\here is u'r db name and path
    OutputStream databaseOutput = new FileOutputStream(outFileName);

    byte[] buffer = new byte[1024];
    int length;
    for(int i=1;i<10;i++){
        databaseInput = myContext.getAssets().open("sport.db.00"+i);\\
        while ((length = databaseInput.read(buffer)) > 0) {
            databaseOutput.write(buffer, 0, length);
            databaseOutput.flush();
        }
        databaseInput.close();
    }

Hope this can help

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜