tags:

views:

72

answers:

0

Hi,

I want to save the SMS I have on my old Samsung SGH-D500. Since the software for it doesn't save the time for exported messages, I copied messages to the SIM card and backuped them on Android using the following code:

    Cursor c = getContentResolver().query(Uri.parse("content://sms"), null, null, null, null);
    startManagingCursor(c);
    String text = "";
    for(String name : c.getColumnNames()){
        text += name+"\t";
    }
    text += "\n";
    while(c.moveToNext()){
        for(int i=0; i<c.getColumnCount(); i++){
            text += c.getString(i)+"\t";
        }
        text += "\n";
    }
    Log.d("sms", text);
    File root = Environment.getExternalStorageDirectory();
    if(root.canWrite()){
        File export = new File(root, "sms.txt");
        try {
            BufferedWriter bw = new BufferedWriter(new FileWriter(export));
            bw.write(text);
            bw.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

The first problem is that it only gets the messages that are on the phone. So I have to copy each message (there's no copy all) to the phone first.
The second problem is that Android doesn't even recognize sent messages I put on the SIM card (SIM card is full but Android shows nothing).

I looked into the Sim Toolkit, but didn't really know where to start. Isn't there something like "content://icc/adn" (contacts) just for SMS?

Thanks
Ralf