安卓:找不到把数据库文件是我的包文件夹? [英] Android: Can't find my package folder to put the database file in it?

查看:130
本文介绍了安卓:找不到把数据库文件是我的包文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Eclipse中使用文件资源管理器以及Android的新的。

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

我已经用的SQLite 数据库并添加一些数据。该数据库被命名为 dbtaxi 的。

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

我的包名为 com.syariati.finalProject

然后我这个设备数据库保存到我的桌面,帮我用检查其内容 SQLite的经理火狐浏览器安装 。然后,我已经使用SQLite Manager,它可能是造成问题增加了一些数据。

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.

我的要求是在我的包来替代数据库( com.syariati.finalProject /数据库/ dbtaxi )使用 dbtaxi 在我的桌面上。但是,我找不到路径 com.syariati.finalProject

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.

需要帮助!谢谢。

推荐答案

你的数据库是一个私有文件夹数据/数据​​/ com.syariati.finalProject /数据库/ dbtaxi。没有生根手机,您就不能访问该文件夹。

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]));
  }
}

这篇关于安卓:找不到把数据库文件是我的包文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆