2016-05-15 21 views
-1

最近アンドロイドアプリを作り始めました。私が今作業しているアプリはクリッカーゲームです。私はプレーヤーのお金を節約するためにアプリが必要です。 mySQLを使用せずにできることはありますか? ここに私のMainActivityコードがあります。Androidアプリでデータを保存

import android.support.v7.app.AppCompatActivity; 
import android.os.Bundle; 
import android.view.View; 
import android.view.WindowManager; 
import android.widget.ImageButton; 
import android.widget.TextView; 

public class MainActivity extends AppCompatActivity { 
    int balance; 
    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_main); 
     //Hide notification bar 
     getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); 
     //Click counter 
     final TextView text = (TextView) findViewById(R.id.balance_text); 
     assert text != null; 
     text.setText("0"); 
     final ImageButton button = (ImageButton) findViewById(R.id.click_button); 
     assert button != null; 
     button.setOnClickListener(new View.OnClickListener(){ 

        @Override 
        public void onClick(View v){ 
         balance++; 
         text.setText("" + balance); 
        } 
       }); 
    } 
} 
+1

MySQLだけではありません。データをアプリにローカルに保存するか、リモートでオンラインにして他のアプリからアクセスできるようにするかは指定していません –

+0

あなたのためにアプリを書くつもりはありません。 SharedPreferencesを試したい場合は、[トレーニングのドキュメント](http://developer.android.com/training/basics/data-storage/shared-preferences.html) –

+0

を参照してください。Sqlite、Cloud、共有プレフィックス、ローカルファイル、コンテンツプロバイダへの書き込み – Pomagranite

答えて

1

Storage Optionsという素晴らしい記事があります。あなたのユースケースに最適なアプローチを選んでください。恐らくSharedPreferencesが最も適切な解決策になります。

+0

SharedPreferencesを自分のコードに入れてください。 –

+1

私はできません、私はあなたのコードを書くことはあなたの仕事だと信じています。 – Egor

+0

私はたくさんのgoogleingをやったが、私はまだそれをやる方法がわからない、本当にそれが必要な私を助けてください。 –

関連する問題