开发者

how do we store all the sms into a single file in android

开发者 https://www.devze.com 2023-03-12 23:20 出处:网络
Hello friends I want to store all the messages from my inbox, drafts, outbox, and sent items into a file using an android application. Is there any way this can be done?

Hello friends

I want to store all the messages from my inbox, drafts, outbox, and sent items into a file using an android application. Is there any way this can be done?

Than开发者_运维技巧ks in advance


Here I literally just take the SMS messages and save them directly as a text file on the SD card.

    Columns message = ColumnsFactory.messages(); //points to structutre
    messages = getContentResolver().query(Uri.parse("content://sms/"),
            null, null, null, null);

    try {
        Files.checkStorage(this);
    } catch (IOException e){
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    PrintStream print = Files.printMessageLog(this);
    print.println(messages.getCount());
    int savedMessages = 0;
    float total = messages.getCount();


    while (messages.moveToNext()) {
        if (message.hasField(messages, "address")) {
            print.println(message.cursorToJSON(messages));
            savedMessages += 1;

        } else {
            total -= 1;

        }
    }
    print.close();
    messages.close();


put them in a xml file that you store in the SD for example ! SMS Backup & Restore 's doing it perfectly ;-)

0

精彩评论

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