jeudi 7 avril 2016

Reading a String array from Sqlite Database - Java

I have declared and inserted in my Sqlite database a String array. Here you have the corresponding code:

@DatabaseField(dataType = DataType.SERIALIZABLE,columnName = paths)
private String[] _paths;    
_paths = new String[3];

_paths[0] = "/Users/Important_Folder/i.jpg";
_paths[1] = "/Users/Very_Important_Folder/r.jpg";
_paths[2] = "/Users/Crucial_Folder/z.jpg";

Now, I would like to retrieve the String array from the database. In order to do so, I used the following code:

byte[] bytes;
result = statement.executeQuery("SELECT paths FROM Table);
bytes = result.getBytes("paths");
System.out.println("The String array is:"+ new String(bytes));

However, I obtain:

¬í ur  [Ljava.lang.String;­ÒVçé{G  xp    t p/Users/Important_Folder/i.jpg p/Users/Very_Important_Folder/r.jpg p/UsersCrucial_Folder/z.jpg

Which is not what I wanted at all.

I really do not know what is going on. Could you help me please ?

Aucun commentaire:

Enregistrer un commentaire