从Google Nexus中读取文件

时间:2012-05-14 19:16:35

标签: android rdf

我试图从谷歌nexus访问一个rdf文件.....(现在这段代码能够从光盘访问rdf文件)....因为google nexus没有sdcard插槽.....所以我有问题来定义从中检索rdf文件的路径....

   public class andro extends Activity implements View.OnClickListener{
    /** Called when the activity is first created. */

Graph graph;
Load ld;
Mappings map;
QueryProcess exec;
ResultFormat f;
RDFFormat f3;

Button runbtn;
Button clearbtn;
Button test;
Button triple;
EditText et1;
TextView tv1;

@Override
   public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.query);


   clearbtn = (Button) findViewById(R.id.clear) ;
   runbtn = (Button) findViewById(R.id.run);
   test = (Button) findViewById(R.id.test);
   triple = (Button) findViewById(R.id.rdf);

   tv1 = (TextView) findViewById(R.id.output); 
   et1 = (EditText) findViewById(R.id.input);


   clearbtn.setOnClickListener(new OnClickListener(){
       public void onClick(View v){
           et1.setText("");
           tv1.setText("");


       }
   });
      test.setOnClickListener(new OnClickListener(){
    //runbtn.setOnClickListener(new OnClickListener(){
      public void onClick(View v){

 /*     String op = et1.getText().toString();   
      tv1.setText(op);  
 */
   // graph = Graph.create();    
     graph = Graph.create(true);

      ld = Load.create(graph);
      ld.load("/user/roy/home/DownLoad/foaf.rdf");
     // ld.load("dataset.rdf");
     /* 
      try {
        ld.loadWE("dataset.rdf");
    } catch (LoadException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }
     */ 
     // String query = null;
    //  Mappings map = null;


    //   String query1 = "select * where {?x ?p ?y}";

     exec = QueryProcess.create(graph); 
     query1 = et1.getText().toString();
      try {
          map = exec.query(query1);
            } catch (EngineException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        // f = ResultFormat.create(map);
        // f3 = TripleFormat.create(map);
         String f2 = ld.toString();
         tv1.setText(ld);   
        //System.out.println(f2);           

         }  
      });

   }  

@Override
public void onClick(View v) {
    // TODO Auto-generated method stub

}   
 }

提前致谢....

1 个答案:

答案 0 :(得分:1)

虽然Nexus没有可移动SD卡,但它基本上仍然有内置卡。因此,使用外部存储器,您可以像平常一样处理它,如果您可以移除SD卡:

String SD_CARD = Environment.getExternalStorageDirectory() + "/my/path";