java - How to access Sqllite DB installed in android from web portal through USB -
we have android app , web portal developed in java client, sqllite
db installed in android app. want offline sync, in order connecting android device pc through usb
. possible access sqllite db installed in android device web portal?
i appreciate answer.
i dont think can directly access usb database stored in apllications private memory not in sdcard,but can export database via code in app (just viewing purpose) , upload file server
public class exportdb { final static string sample_db_name = "yourdatabase"; public static void exportdb(context context){ file sd = environment.getexternalstoragedirectory(); file data = environment.getdatadirectory(); filechannel source=null; filechannel destination=null; string currentdbpath = "/data/"+ "your.package.name" +"/databases/"+sample_db_name; string backupdbpath = sample_db_name; file currentdb = new file(data, currentdbpath); file backupdb = new file(sd, backupdbpath); try { source = new fileinputstream(currentdb).getchannel(); destination = new fileoutputstream(backupdb).getchannel(); destination.transferfrom(source, 0, source.size()); source.close(); destination.close(); toast.maketext(context, "db exported!", toast.length_long).show(); } catch(ioexception e) { e.printstacktrace(); } } }
Comments
Post a Comment