3

I'm trying to convert an android.graphics.Path object to byte[] so that I could store it in a blob storage in SQLite, also to convert it back.

So far I don't even know where to begin...

Thanks to anyone willing to help.

0

2 Answers 2

2

As Path extends Object, you can use something like this:

    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    ObjectOutputStream objectOutputStream = new ObjectOutputStream(outputStream);
    objectOutputStream.writeObject(path);
    byte[] array = outputStream.toByteArray();
Sign up to request clarification or add additional context in comments.

2 Comments

Since Path is not serializable, trying this will throw a java.io.NotSerializableException: android.graphics.Path
@jhnewkirk You can make a serialized class Path by overriding the methods before the C native methods calls.
1

Serialize your object and upload that file .

ByteArrayOutputStream baos = new ByteArrayOutputStream()
ObjectOutput out = new ObjectOutputStream(baos);
out.writeObject(android.graphics.Path);
out.close()
byte[] buf = bos.toByteArray();  //byte array

to recover that object use deserialization

ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(buf)); 
      class_name recover =(clas_name) in.readObject(); 
      in.close(); 
      return object;

1 Comment

System.err: java.io.NotSerializableException: android.graphics.Path

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.