2011-11-02 54 views
0

我正在編譯運行在Android 2.2上的語言字典。我的方案是我想將單詞添加到收藏夾列表,然後查看保存的收藏夾。實際上,我想將喜歡的單詞保存到在SD卡上創建的(文本)文件中,當用戶單擊「查看收藏夾」時,此文件中的單詞將顯示並可以選擇。如何保存到收藏夾並獲取保存的收藏夾以顯示

問題是我不知道如何編碼「保存和查看」收藏列表。

這裏是我的代碼:

btnAddFavourite = (ImageButton) findViewById(R.id.btnAddFavourite); 

btnAddFavourite.setOnClickListener(new View.OnClickListener() { 

      @Override 
      public void onClick(View v) { 
       // I want the code here! 
       Toast toast = Toast.makeText(ContentView.this, R.string.messageWordAddedToFarvourite, Toast.LENGTH_SHORT); 
       toast.show(); 
      } 
     }); 

    btnAddFavourite.setOnLongClickListener(new View.OnLongClickListener() { 

      @Override 
      public boolean onLongClick(View v) { 

       // Open the favourite Activity, which in turn will fetch the saved favourites, to show them. 
       Intent intent = new Intent(getApplicationContext(), FavViewFavourite.class); 
       intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
       getApplicationContext().startActivity(intent); 

       return false; 
      } 
     }); 

我不知道是否有這個問題的解決方案,以及如何我可以編寫代碼來解決這個問題。非常感謝你。

回答

0

嗯,解決什麼問題?即使數據庫是更好的解決方案,文本文件也可以工作。怎麼了 ?