android studio get shared preferences

Yazmak için

if(jsonResult == 1){
Intent intent = new Intent(MainActivity.this, LoginActivity.class); intent.putExtra("USERNAME", enteredUsername); intent.putExtra("MESSAGE", "You have been successfully login");
SharedPreferences userDetails = getApplicationContext().getSharedPreferences("kullanicibilgisi", MODE_PRIVATE); SharedPreferences.Editor edit = userDetails.edit(); edit.clear(); edit.putString("kullaniciadi", username.getText().toString()); edit.putString("parola", password.getText().toString()); edit.commit();

okumak için

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); setContentView(R.layout.activity_main);
SharedPreferences userDetails = getSharedPreferences("kullanicibilgisi", MODE_PRIVATE); String test1 = userDetails.getString("kullaniciadi", ""); String test2 = userDetails.getString("parola", ""); Toast.makeText(getApplicationContext(), test1, Toast.LENGTH_LONG).show(); Toast.makeText(getApplicationContext(), test2, Toast.LENGTH_LONG).show();

android studio shared preferences

Define some statics to store the preference file name and the keys you’re going to use:
public static final String PREFS_NAME = "MyPrefsFile";
private static final String PREF_USERNAME = "username";
private static final String PREF_PASSWORD = "password";
You’d then save the username and password as follows:
getSharedPreferences(PREFS_NAME,MODE_PRIVATE)
.edit()
.putString(PREF_USERNAME, username)
.putString(PREF_PASSWORD, password)
.commit();
So you would retrieve them like this:
SharedPreferences pref = getSharedPreferences(PREFS_NAME,MODE_PRIVATE);   
String username = pref.getString(PREF_USERNAME, null);
String password = pref.getString(PREF_PASSWORD, null);

if (username == null || password == null) {
//Prompt for username and password
}
Alternatively, if you don’t want to name a preferences file you can just use the default:
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);

android studio php json tips

android studioda php kullanırken notepad++da encoding in utf-8 olması gerekir bomsuz olması gerekir.
phpde jsonda dönen degerde turkce karakter hatalıysa

<?php
header(‘Content-Type: text/html; charset=utf-8’);
require_once(“baglan.php”);//database bağlantısı gercekleştirdik
………….

….

echo utf8_encode(json_encode($cevap));// json verisini yazdırdık
}else{
echo “Giriş Engellendi”;
}
?>

httpclient and HttpURLConnection

                    HttpClient httpclient = new DefaultHttpClient();
                    HttpPost httppost = new HttpPost(“http://192.168.43.94/spinner.php&#8221;);
                    HttpResponse response = httpclient.execute(httppost);
                    is = entity.getContent();
                    Log.e(“Fail 1”, “3”);

——————————–

                    URL url = new URL(“http://192.168.43.94/spinner.php&#8221;);
                    urlConnection = (HttpURLConnection) url.openConnection();
                    urlConnection.connect();
                    is = urlConnection.getInputStream();

apk inspector

İnstalling firstt 
Windows:

  1. Download Windows wrapper script (Right click, Save Link As apktool.bat)
  2. Download apktool-2 (find newest here)
  3. Rename downloaded jar to apktool.jar
  4. Move both files (apktool.jar & apktool.bat) to your Windows directory (Usually C://Windows)
  5. If you do not have access to C://Windows, you may place the two files anywhere then add that directory to your Environment Variables System PATH variable.
  6. Try running apktool via command prompt

then put in same directory the apk u want to decompile and
run cmd and go to directory a.apk
and apktool if a.apk
and apktool d a.apk d:\a\decompiledapk

ANDROID STUDIO ARRAY LIST

public class RemindersActivity extends ActionBarActivity {
private ListView mListView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_reminders);
mListView = (ListView) findViewById(R.id.reminders_list_view);
//The arrayAdatper is the controller in our
//model-view-controller relationship. (controller)
ArrayAdapter arrayAdapter = new ArrayAdapter(
//context
this,
//layout (view)
R.layout.reminders_row,
//row (view)
R.id.row_text,
//data (model) with bogus data to test our listview
new String[]{“first record”, “second record”, “third record”});
mListView.setAdapter(arrayAdapter);
}
//

android studio valuesda xml dosyasından spinnere alma

once valuesa sağ tıkla ve new xml value adınıda gunler koy
içinde :

   
        Pazartesi
        Salı
        Çarşamba
        Perşembe
        Cuma
        Cumartesi
        Pazar
   

layout: activity_maine 1 adet spinner1 isminde spiner yarat
. java : MainActivity
package com.abysamltd.myapplication;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import android.widget.Toast;
public class Main_Activity extends AppCompatActivity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //Spinner spinner = (Spinner) findViewById(R.id.spinner);
        android.widget.Spinner spinner = (android.widget.Spinner) findViewById(R.id.spinner1);
        ArrayAdapter adapter = ArrayAdapter.createFromResource(
                this, R.array.gunler, android.R.layout.simple_spinner_item);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        spinner.setAdapter(adapter);
        spinner.setOnItemSelectedListener(new MyOnItemSelectedListener());
    }
    public class MyOnItemSelectedListener implements AdapterView.OnItemSelectedListener {
        public void onItemSelected(AdapterView parent,
                                   View view, int pos, long id) {
            Toast.makeText(parent.getContext(), “Seçilen gün ” +
                    parent.getItemAtPosition(pos).toString(), Toast.LENGTH_LONG).show();
        }
        public void onNothingSelected(AdapterView parent) {
            // Do nothing.
        }
    }
}