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 ;-)
精彩评论