[Simple-support] PersistenceException: constructor not matched for class error when deserializing X
Brought to you by:
niallg
|
From: Thalisson Da R. <tal...@gm...> - 2011-01-24 18:32:18
|
Hi,
I'm using Simple to create an XML file called BackupInfo.xml from this
class:
@Root
public class BackupInfo {
@Attribute
private String backupName;
@Element
private int numberOfFiles;
@ElementList
private ArrayList<FileInfo> files;
@Element
private Date date;
}
@Root
class FileInfo{
@Attribute
public String fileName;
@Element
private String path;
@Element
private long fileSize;
public FileInfo(String name, String aPath, long size) {
fileName = name;
path = aPath;
fileSize = size;
}
public String getName(){
return fileName;
}
public String getPath(){
return path;
}
}
When I serialize it I get a XML file that looks like this:
- <#> <backupInfo backupName="1">
<files>
<fileInfo>
<fileName>sms.xml</fileName>
<path>/sdcard/sms.xml</path>
<fileSize>2807</fileSize>
</fileInfo>
<fileInfo>
<fileName>calllog.xml</fileName>
<path>/sdcard/calllog.xml</path>
<fileSize>1611</fileSize>
</fileInfo>
<fileInfo>
<fileName>contacts.xml</fileName>
<path>/sdcard/contacts.xml</path>
<fileSize>1679</fileSize>
</fileInfo>
</files>
<date>2011-01-21 16:55:15.63 GMT+00:00</date>
<numberOfFiles>3</numberOfFiles>
</backupInfo>
Then I try to deserialize using:
serializer = new Persister();
File info = new File ("/sdcard/BackupInfo.xml");
BackupInfo bi = serializer.read(BackupInfo.class, info);
At this point, I get the PersistenceException: Constructor not matched for
class com.data.FileInfo
How do I solve this error? I searched everywhere (tutorial, google, this
mail list) but couldn't find an answer.
Thx,
Thalisson
|