Android Open Source - UndumpToWebSql Util






From Project

Back to project page UndumpToWebSql.

License

The source code is released under:

MIT License

If you think the Android project UndumpToWebSql listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.example.sqliteinjection.app;
//from   ww  w  .j  a  v a 2s.c o m
import android.content.Context;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.channels.Channels;
import java.nio.channels.FileChannel;
import java.nio.channels.ReadableByteChannel;

/**
 * Just Util :)
 */
public class Util {
    static void extractAsset(Context context, String src, File dest) {
        try {
            File parentFile = dest.getParentFile();
            if (!parentFile.exists()) {
                parentFile.mkdirs();
            }

            InputStream inputStream = context.getAssets().open(src);
            int size = inputStream.available();
            ReadableByteChannel input = Channels.newChannel(inputStream);
            FileChannel output = new FileOutputStream(dest).getChannel();
            output.transferFrom(input, 0, size);

            output.close();
            input.close();
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }
}




Java Source Code List

com.example.sqliteinjection.app.MainActivity.java
com.example.sqliteinjection.app.MyDbOpenHelper.java
com.example.sqliteinjection.app.Util.java