[Android Studio] thegioiao190@gmail.com:
Hello everyone, i want to connect file shared on my windows

I make app android to view file on any windows by share file

but i have a problem

please help me!

this is my code:

NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication("","wd","admin123");

String path = "smb://10.10.120.195/Share/a.txt";

try {

SmbFile file = new SmbFile(path, auth);

file.connect();

}

catch(Exception e)

{

}

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ problem

D/libc-netbsd: [getaddrinfo]: ai_addrlen=0; ai_canonname=(null); ai_flags=4; ai_family=0

D/AndroidRuntime: Shutting down VM

E/AndroidRuntime: FATAL EXCEPTION: main

Process: com.example.admin.myapplication, PID: 12663

java.lang.ExceptionInInitializerError

at jcifs.netbios.NbtAddress.getWINSAddress(NbtAddress.java:533)

at jcifs.UniAddress.<clinit>(UniAddress.java:62)

at jcifs.smb.SmbFile.getFirstAddress(SmbFile.java:922)

at jcifs.smb.SmbFile.connect(SmbFile.java:1012)

at com.example.admin.myapplication.MainActivity.onCreate(MainActivity.java:31)

at android.app.Activity.performCreate(Activity.java:6309)

at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1113)

at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2519)

at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2654)

at android.app.ActivityThread.-wrap11(ActivityThread.java)

at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1488)

at android.os.Handler.dispatchMessage(Handler.java:111)

at android.os.Looper.loop(Looper.java:207)

at android.app.ActivityThread.main(ActivityThread.java:5728)

at java.lang.reflect.Method.invoke(Native Method)

at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)

at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)

Caused by: android.os.NetworkOnMainThreadException

at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1288)

at java.net.InetAddress.lookupHostByName(InetAddress.java:432)

at java.net.InetAddress.getLocalHost(InetAddress.java:410)

at jcifs.netbios.NbtAddress.<clinit>(NbtAddress.java:187)

at jcifs.netbios.NbtAddress.getWINSAddress(NbtAddress.java:533)*

at jcifs.UniAddress.<clinit>(UniAddress.java:62)*

at jcifs.smb.SmbFile.getFirstAddress(SmbFile.java:922)*

at jcifs.smb.SmbFile.connect(SmbFile.java:1012)*

at com.example.admin.myapplication.MainActivity.onCreate(MainActivity.java:31)*

at android.app.Activity.performCreate(Activity.java:6309)*

at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1113)*

at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2519)*

at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2654)*

at android.app.ActivityThread.-wrap11(ActivityThread.java)*

at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1488)*

at android.os.Handler.dispatchMessage(Handler.java:111)*

at android.os.Looper.loop(Looper.java:207)*

at android.app.ActivityThread.main(ActivityThread.java:5728)*

at java.lang.reflect.Method.invoke(Native Method)*

at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)*

at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)*

I/System: FinalizerDaemon: finalize objects = 1

help me! please!