-->

Android: Can't find my package folder to put t

2019-08-24 02:28发布

问题:

I am new in using File Explorer in eclipse as well as Android.

I have created a database using SQLite and added few data. The database is named dbtaxi.

My package name is com.syariati.finalProject

Then I saved this device database onto my desktop to help me check its content using SQLite Manager, firefox addons. Then I have added some data using SQLite Manager, which is possible is causing the problem.

My requirement is to replace database in my package (com.syariati.finalProject/Databases/dbtaxi) with dbtaxi on my Desktop. But, I can't find the path com.syariati.finalProject.

Need help! Thank you.

回答1:

Your db is in a private folder "data/data/com.syariati.finalProject/databases/dbtaxi". You cannot access that folder without rooting the phone.

Another option is to copy the db to that folder programatically.

import java.io.*;
import java.nio.channels.*;

public class FileUtils{
    public static void copyFile(File in, File out) 
        throws IOException 
    {
        FileChannel inChannel = new
            FileInputStream(in).getChannel();
        FileChannel outChannel = new
            FileOutputStream(out).getChannel();
        try {
            inChannel.transferTo(0, inChannel.size(),
                    outChannel);
        } 
        catch (IOException e) {
            throw e;
        }
        finally {
            if (inChannel != null) inChannel.close();
            if (outChannel != null) outChannel.close();
        }
    }

    public static void main(String args[]) throws IOException{
        FileUtils.copyFile(new File(args[0]),new File(args[1]));
  }
}


回答2:

It's in "/data/data/com.syariati.finalProject/databases".



回答3:

/data/data/com.syariati.finalProject/databases

. . . .