How to Write from Byte Array Buffer

OutputStream.write() was added in API Level 1
write (byte[] buffer, int offset, int count)
Writes count bytes from the byte array buffer starting at position offset to this stream.

1. Create a new FileOutputStream saved to myOutputStream with the FileOutStream below. Replace mypackagename with your package name.

 "/data/data/mypackagename/mySQLiteDatabase.db"

2. Declare and Set an Byte Array named myByteArray and set to 1024.

3. Add the code below to the onCreate method. This will create a try/catch statement that will write the byte array named myByteArray, starting at 0, a length of 3 bytes. 

try {
        myOutputStream.write(myByteArray, 0, 3);
} catch (IOException e) {

        e.printStackTrace();
}


4. Compile and run!

Next Recommended Article: How to Add an External SQLite database
Web hosting