Aller au contenu
View in the app

A better way to browse. Learn more.

Forum de Frandroid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

comment récupérent les données stockent dans les préférences partagées .

Featured Replies

Posté(e)

salut tout le monde

mon but est de stocker les données détectent par le GPS intégrer dans smartphone ;

Il existe plusieurs manières de procéder ,mais j'ai choisi les préférences partagées .

voici mon code (juste pour enregistre quelques valeurs ):

package PFE.Lirefichier;

import android.app.Activity;

import android.content.SharedPreferences;

import android.os.Bundle;

import android.widget.Toast;

public class main extends Activity {

public static final String PREFS_NAME="MayPresFile";

public static final String text1=" bonjour tout le monde ";

public static final String text2=" bonjour ";

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

SharedPreferences myPrefs = this.getSharedPreferences(PREFS_NAME, MODE_WORLD_READABLE | MODE_APPEND);

SharedPreferences.Editor prefsEditor = myPrefs.edit();

prefsEditor.putLong("2",26);

prefsEditor.putLong("3",27);

prefsEditor.putLong("4",28);

prefsEditor.commit();

for(int i=1;i<=4;i++){

SharedPreferences myPrefs1 = this.getSharedPreferences("MayPresFile", MODE_WORLD_READABLE);

Long prefName = myPrefs1.getLong("i", 0);

Toast.makeText(this, " la valeur est :" +prefName + "\n" , Toast.LENGTH_LONG).show();

}

}

}

mais il m'affiche la dernière valeur ( 28),

merci d'avance

  • 3 weeks later...
Posté(e)

et si tu remplaçais

myPrefs1.getLong("i", 0);

par

myPrefs1.getLong(""+i, 0);

??

Archivé

Ce sujet est désormais archivé et ne peut plus recevoir de nouvelles réponses.

Account

Navigation

Rechercher

Rechercher

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.