Não dá erro, ele só roda o catch() msm. Fui no Log, também não ter erro, mas no run dá o segunte:
> Build Date : 12/27/18
> OpenGL ES Shader Compiler Version: EV031.25.03.02
> Local Branch :
> Remote Branch : refs/tags/AU_LINUX_ANDROID_LA.UM.7.5.R1.09.00.00.464.037
> Remote Branch : NONE
> Reconstruct Branch : NOTHING
> Build Config : S L 6.0.7 AArch32
> I/Adreno: PFP: 0x005ff110, ME: 0x005ff066
> I/ConfigStore: android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasWideColorDisplay retrieved: 0
> android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasHDRDisplay retrieved: 0
> I/OpenGLRenderer: Initialized EGL, version 1.4
> D/OpenGLRenderer: Swap behavior 2
> W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@59d2653
> D/OpenGLRenderer: endAllActiveAnimators on 0x8aeb3100 (RippleDrawable) with handle 0x8aed2930
> W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@f47a498
> W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@db8575c
> W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@ced9103
> W/System.err: java.io.FileNotFoundException: /storage/emulated/0/BACKUP_APP_ESCOLA (Is a directory)
> W/System.err: at java.io.FileInputStream.open0(Native Method)
> W/System.err: at java.io.FileInputStream.open(FileInputStream.java:231)
> at java.io.FileInputStream.<init>(FileInputStream.java:165)
> at sistema.escola.BancoDeDados.importacaoBanco(BancoDeDados.java:253)
> at sistema.escola.UploadDoBanco$1.onClick(UploadDoBanco.java:36)
> at android.view.View.performClick(View.java:6600)
> at android.view.View.performClickInternal(View.java:6577)
> at android.view.View.access$3100(View.java:781)
> W/System.err: at android.view.View$PerformClick.run(View.java:25912)
> at android.os.Handler.handleCallback(Handler.java:873)
> at android.os.Handler.dispatchMessage(Handler.java:99)
> at android.os.Looper.loop(Looper.java:193)
> at android.app.ActivityThread.main(ActivityThread.java:6923)
> at java.lang.reflect.Method.invoke(Native Method)
> at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
> W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:870)
Ele disse que é uma pasta em:
/storage/emulated/0/BACKUP_APP_ESCOLA (Is a directory)
Daí fiz assim:
public String importacaoBanco() {
String retorno = null;
File arquivoDeOrigem = new File(Environment.getExternalStorageDirectory() + "/BACKUP_APP_ESCOLA/ARQUIVO_DE_BACKUP");
File arquivoDestinoSistema = new File(Environment.getDataDirectory()+"//data/data/sistema.escola/databases/Escola.db");
try {
FileChannel input = new FileInputStream(arquivoDeOrigem).getChannel();
FileChannel Output = new FileOutputStream(arquivoDestinoSistema).getChannel();
Output.transferFrom(input, 0, input.size());
input.close();
Output.close();
return retorno = "UPLOAD REALIZADO COM SUCESSO!";
}
catch (IOException e) {
e.printStackTrace();
return retorno = "UPLOAD NÃO REALIZADO!";
}
}
alterei a pastaOrigem para arquivoDeOrigem:
File arquivoDeOrigem = new File(Environment.getExternalStorageDirectory() + "/BACKUP_APP_ESCOLA/ARQUIVO_DE_BACKUP");
Continua rodando o catch(), mas dessa vez o input rodou e parou no output. Segue o Run:
Accessing hidden field Landroid/graphics/Insets;->left:I (light greylist, linking)
Accessing hidden field Landroid/graphics/Insets;->right:I (light greylist, linking)
Accessing hidden field Landroid/graphics/Insets;->top:I (light greylist, linking)
Accessing hidden field Landroid/graphics/Insets;->bottom:I (light greylist, linking)
W/sistema.escola: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (light greylist, reflection)
W/sistema.escola: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (light greylist, reflection)
W/sistema.escola: Accessing hidden method Landroid/widget/TextView;->getTextDirectionHeuristic()Landroid/text/TextDirectionHeuristic; (light greylist, linking)
W/sistema.escola: Accessing hidden method Landroid/graphics/FontFamily;-><init>()V (light greylist, reflection)
W/sistema.escola: Accessing hidden method Landroid/graphics/FontFamily;->addFontFromAssetManager(Landroid/content/res/AssetManager;Ljava/lang/String;IZIII[Landroid/graphics/fonts/FontVariationAxis;)Z (light greylist, reflection)
Accessing hidden method Landroid/graphics/FontFamily;->addFontFromBuffer(Ljava/nio/ByteBuffer;I[Landroid/graphics/fonts/FontVariationAxis;II)Z (light greylist, reflection)
Accessing hidden method Landroid/graphics/FontFamily;->freeze()Z (light greylist, reflection)
Accessing hidden method Landroid/graphics/FontFamily;->abortCreation()V (light greylist, reflection)
W/sistema.escola: Accessing hidden method Landroid/graphics/Typeface;->createFromFamiliesWithDefault([Landroid/graphics/FontFamily;Ljava/lang/String;II)Landroid/graphics/Typeface; (light greylist, reflection)
D/OpenGLRenderer: Skia GL Pipeline
I/Adreno: QUALCOMM build : 7adeec4758, I21281c58c8
Build Date : 12/27/18
OpenGL ES Shader Compiler Version: EV031.25.03.02
Local Branch :
Remote Branch : refs/tags/AU_LINUX_ANDROID_LA.UM.7.5.R1.09.00.00.464.037
Remote Branch : NONE
Reconstruct Branch : NOTHING
Build Config : S L 6.0.7 AArch32
I/Adreno: PFP: 0x005ff110, ME: 0x005ff066
I/ConfigStore: android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasWideColorDisplay retrieved: 0
android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasHDRDisplay retrieved: 0
I/OpenGLRenderer: Initialized EGL, version 1.4
D/OpenGLRenderer: Swap behavior 2
W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@59d2653
W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@33a2212
W/System.err: java.io.FileNotFoundException: /data/data/data/sistema.escola/databases/Escola.db (No such file or directory)
W/System.err: at java.io.FileOutputStream.open0(Native Method)
at java.io.FileOutputStream.open(FileOutputStream.java:308)
W/System.err: at java.io.FileOutputStream.<init>(FileOutputStream.java:238)
at java.io.FileOutputStream.<init>(FileOutputStream.java:180)
at sistema.escola.BancoDeDados.importacaoBanco(BancoDeDados.java:254)
at sistema.escola.UploadDoBanco$1.onClick(UploadDoBanco.java:36)
W/System.err: at android.view.View.performClick(View.java:6600)
at android.view.View.performClickInternal(View.java:6577)
at android.view.View.access$3100(View.java:781)
W/System.err: at android.view.View$PerformClick.run(View.java:25912)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
W/System.err: at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6923)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:870)
Tem dizendo assim:
W/System.err: java.io.FileNotFoundException: /data/data/data/sistema.escola/databases/Escola.db (No such file or directory)
W/System.err: at java.io.FileOutputStream.open0(Native Method)
at java.io.FileOutputStream.open(FileOutputStream.java:308)
W/System.err: at java.io.FileOutputStream.<init>(FileOutputStream.java:238)
at java.io.FileOutputStream.<init>(FileOutputStream.java:180)
at sistema.escola.BancoDeDados.importacaoBanco(BancoDeDados.java:254)
at sistema.escola.UploadDoBanco$1.onClick(UploadDoBanco.java:36)
(No such file or directory)
Mas o arquivo foi exportado e está na memória externa do celular, com os valores corretos.